June 15, 2006 at 2:24 pm
I know how to drop a table (a sheet in excel file).
DROP TABLE name_of_table
GO
But how do you type the syntax to check if the table exist? (this table again is not a sql server table, but a excel table).
I want to put this logic in the DTS Package SQL Task.
June 16, 2006 at 7:09 am
The easiest way to do this is to use a scripting task and instantiate a file object to see if the file exists. Then instantiate an Excel object and see if the worksheet exists.
To do this in a SQL task would be a bit more difficult because you would have to issue command line shell to do this.
Searching Excel automation tasks will give you syntax examples for the scripting task.
June 16, 2006 at 10:45 am
But I don't know too much about scripting task. Can you give me a good example?
I do recall I have seen the 'IF EXISTING '... in a sql task in DTS Package.
June 16, 2006 at 1:12 pm
You can do a select against the table. If the table does not exists you'll get an error, invalid object name 'MyTable'. Trap for this error in your code and if SQL Server generates this error you know it does not exist.
Hope it helps.
LC
June 19, 2006 at 12:28 pm
This is what you need to know right here!
http://www.sqlservercentral.com/columnists/jsack/capturingtheerrordescriptioninastoredprocedure.asp
[font="Courier New"]ZenDada[/font]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply