x
login about faq Site discussion (meta-askssc)

how do I code path name to a server in a variable in SSIS package

I'm trying to code the server path name in a variable for my flat file destination connection manager so it's easier to change. I don't know whether to put one backslash or two.

I've tried both and get the same error "Attempt to parse the expression "\serverfolder" failed. The token "" at line number "0", character number "0" was not recognized.

The string variable contains. \serverfolder I'm combining this with the file name also stored in a variable.

more ▼

asked Dec 01 '11 at 02:25 PM in Default

Dave__C gravatar image

Dave__C
23 1 1 2

This worked. I appreciate the advice.

Dec 02 '11 at 12:35 PM Dave__C
(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

You need to put double the amount of backslashes. an easy way to test this is to click on the variable, go to the properties window and click on the ellipses in the espression property.

Then type in "\\\servername\c$", and click on Evaluate Expression and it will show it as \servernamec$

EDIT: Backslashes don't work well, there are 4 at the start and 2 in the middle.

more ▼

answered Dec 01 '11 at 06:44 PM

Daniel Ross gravatar image

Daniel Ross
2.9k 6 10 12

(comments are locked)
10|1200 characters needed characters left

Backslashes work well for me. Here is a sample expression I use to generate a filename that starts with "Test_" and ends with today date to UNC file server destination in one of my SSIS packages:

"\\\\fileserver\\Test_" + SUBSTRING( (DT_WSTR,30)GETDATE() , 1, 4 ) + SUBSTRING ( (DT_WSTR,30)GETDATE() , 6, 2 )  + SUBSTRING( (DT_WSTR,30)GETDATE() , 9, 2 )  + ".txt"

When evaluated the above expression returns(today) \\fileserver\Test_20111205.txt

So in your case you should use:

"\\\\ServerName\\c$\\Test_" + SUBSTRING( (DT_WSTR,30)GETDATE() , 1, 4 ) + SUBSTRING ( (DT_WSTR,30)GETDATE() , 6, 2 )  + SUBSTRING( (DT_WSTR,30)GETDATE() , 9, 2 )  + ".txt"

which gives \\ServerName\c$\Test_20111205.txt when evaluated.

more ▼

answered Dec 05 '11 at 12:24 PM

DaniSQL gravatar image

DaniSQL
4.8k 30 35 39

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x749
x24

asked: Dec 01 '11 at 02:25 PM

Seen: 1109 times

Last Updated: Dec 01 '11 at 02:25 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.