Reputation: 353
I am new to SSIS. I have a SSIS package that imports a table from a different SQL Server to mine. I created the package using the import wizard, but I understand how to open and edit using VisualStudio. The basic package drops the original table first, creates the new table then imports the data. I do this daily.
My problem is sometimes the other database isn't available. I don't know there is a problem until after the table drop. I need to know if there is a simple (enough for me) way to check the other table availability before I drop my current copy. That way I keep my most recent data if the new data isn't available.
I thought I could import to a temp table, then check it's row count and if 0 stop there. Or somehow check the other server first before dropping, but I don't know how to do either. Grateful for some pointers.
Edit: Need help figuring out how to do it in SSIS as well as how to do it in general.
Upvotes: 1
Views: 453
Reputation: 107
This is easy enough to accomplish. You have to check for other database tables before dropping is a simple command and here that is:
Pulled the query from here
Permanent Table
IF OBJECT_ID('dbo.Scores', 'U') IS NOT NULL
DROP TABLE dbo.Scores;
Temporary Table
IF OBJECT_ID('tempdb.dbo.#T', 'U') IS NOT NULL
DROP TABLE #T;
That will allow you to delete if the other exists.
Upvotes: 3