I am working on a SSIS package that rejects already loaded files & load only new files to table. I used for each loop and exceute SSQL to validate if the files are already loaded. When I evaluate the expression of Execute SQL Task, it evaluates fine. But When I run the paackage I get the following error.
[Execute SQL Task] Error: Executing the query "DECLARE @FileName VARCHAR(100) SET @FileName=Custo..." failed with the following error: "Incorrect syntax near ''.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
The Expression I used in the Execute SQL task is :
"DECLARE @FileName VARCHAR(100) SET @FileName="+@[User::FileName]+"' IF EXISTS (SELECT 1 FROM [dbo].[FileLoadStatus] WHERE filename =@FileName) BEGIN SELECT 1 AS FileExistsFlg END ELSE BEGIN Select 0 AS FileExistsFlg END"
screen shot of the execute SQL Task
I really apprecaite if you can tell where the problem is ?