October 13, 2006 at 1:35 pm
I am new in SSIS,
and I am building some ETL just to make some exercises.
In the "Execute SQL task" page general and property: SQL Statement, I try to insert this SQL Statement,
"INSERT INTO table SELECT '" + @[User::myVariable] + "'"
or
"INSERT INTO table SELECT '" + @myVariable + "'"
but parsing, I get an error:
incorrect syntiax near '+'.
Do you know any suggestions?
Thank
October 16, 2006 at 8:00 am
This was removed by the editor as SPAM
October 17, 2006 at 9:08 am
Where are you trying to set the SQL statement with the variable? In Expressions I don't see SQL Statement as an available property that you can set?
Tim
Denver, CO
October 18, 2006 at 5:53 am
The best way to accomplish your task is to use Dynamic SQL. You'll have to create a variable to store your SQL Statement and your variable in and then execute that variable because SQL doesn't like adding a variable into the actual execution statement.
Here's an example of what I'm talking about. The below script is an exerpt from a T-SQL job that copies a backup from one network share to another after deleting the previous day's backup file. @OldFileName has already be set using a temp table that reads in the directory from that share.
Declare @removefile As Varchar(200)
set @removefile = 'Del G:\SQL_BAK\apacs\CopyForQCDev\' + @OldFileName;
Exec Master..Xp_cmdshell @removefile;
Does that make sense? If not, let me know.
October 25, 2006 at 6:42 am
Hi,
thank for your reply, I solved the problem:
before I had a mistake inserting the INSERT... into SQL statement, then I moved to the expression field and now it works.
Thank
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply