I have a file i want to attach in a send db mail task but the file name is a variable. When I build the whole path and filename as a sql expression - it does not resolve the expression as the filename. Here is my expression - @file_attachments = \\\\Export'+REPLACE(CONVERT(char(8), getdate(), 10), '-', '')+'zip' It fails around the "+" Error message Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '+'.
If that is the exact statement from your code, you are missing the leading quote in the expression. Should be: @file_attachments = '\\\\Export'+REPLACE(CONVERT(char(8), getdate(), 10), '-', '')+'zip' Apart from that I can't find any problems with the statement.