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.
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.
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.