execute sql task expression does not work
Hello, i'm using sql server 2008 R2 standard. I have an ssis package with an Execute sql task Control flow item. This executes an expression. This expression (with 2 variables) works: "select * into OLTP." + @[User::destinationtable] + " FROM OPENROWSET('MSDASQL', 'DSN=Teamsoft Productie;UID=odbc;PWD=te@ms0ft', 'SELECT * from PUB." + @[User::sourcetable] + "')" + " GO" But now I don't want a select *, but a selection of all columns, except for the column names ending with _memo. So I made this expression: "select * into OLTP." + @[User::destinationtable] + " FROM OPENROWSET('MSDASQL', 'DSN=Teamsoft Productie;UID=odbc;PWD=te@ms0ft', 'SELECT 'SELECT '+stuff( (select ',' + name as [text()] FROM [TEAMSOFT_OLTP].[sys].[columns] WHERE OBJECT_ID=OBJECT_ID(" +@[User::sourcetable] + ") AND name NOT LIKE '%_memo' order by name for xml path('')), 1, 1, '') + from PUB." + @[User::brontabel] + "')" + " GO" WHen I evaluate this expression, I get no error messages, but when I execute the package, i get the error: [Execute SQL Task] Error: Executing the query "select * into OLTP.fn006 FROM OPENROWSET('MSDASQL..." 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. I tried different rewrites of the expression, but nothing works. The query which selects al columns except for the columns ending with '_memo' works too, I tested it with fixed table names. Regards, Hennie
August 27th, 2012 8:30am

Fetch the expression after testing and put in SSMS, try and adjust. If it is working, take this statementput in your expression and change the real tablenames to your variable.
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2012 10:53am

Or try another way to get the columns not ending with '_memo' by using INFORMATION_SCHEMA.COLUMNS.
August 27th, 2012 12:13pm

did you set default values for destinationtable and sourcetable user variables? SSIS will check them at the time of evaluating expression and compiling ssis package, so provide default valid values, don't worry about these defaults because at runtime these values will be overwritten with actual values resolved at runtime.http://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2012 4:41pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics