Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Using a variable in an execute sql task to check for the existence of a table.

$
0
0

Hi,

Pretty new to SSIS. I have checked for this and seen posts that imply the syntax I need but I have not been able to make any of them work.

As of now I am checking for the existence of a table in an execute sql task. This is proof of concept;I eventually will delete the table if it exists

declare @Dummy char

If (select 1 from information_schema.tables where table_name = ?) = 1
  set @Dummy='a'
else
  set @Dummy='b'

I set up a variable in this task with the name '"0" as I've seen in other posts. With the above code I get the following error:

[Execute SQL Task] Error: Executing the query "declare @Dummy char

If (select 1 from information..." failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

I have tried other syntax such as replacing the ? with the name of the variable (@Thetable) or User::TheTable. I have also tried these with the if exist (select * from table) syntax. Nothing seems to work.

Any advice would be appreciated.

Fig000


Fig000


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>