question

Dave__C avatar image
Dave__C asked

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 "\\server\folder\" failed. The token "\" at line number "0", character number "0" was not recognized. The string variable contains. \\server\folder\ I'm combining this with the file name also stored in a variable.
ssisvariable
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

This worked. I appreciate the advice.
0 Likes 0 ·
Daniel Ross avatar image
Daniel Ross answered
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 \\\servername\c$ EDIT: Backslashes don't work well, there are 4 at the start and 2 in the middle.
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DaniSQL avatar image
DaniSQL answered
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.
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.