dbTalk Databases Forums  

Adding logic to check for existence of soource tables

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Adding logic to check for existence of soource tables in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
carolus.holman
 
Posts: n/a

Default Adding logic to check for existence of soource tables - 06-09-2006 , 08:38 AM






I am runnng into a situtation with a vendor who does not load their database
consistently. Sometimes a table is missing from their db. It is a lookup
table so is not critical. What I want to do is check for the existence of the
table in the source db, before I drop my local table. My package fails
because this table is not present. I have tried checking it a few different
ways, however how can I check for soemthing that does not exist, without my
package failing?

Reply With Quote
  #2  
Old   
David Lundell
 
Posts: n/a

Default Re: Adding logic to check for existence of soource tables - 06-09-2006 , 03:45 PM






Carolus:

If I understand your problem correctly this should work.

Assumption: Source and Destination are SQL Servers

Setup a SQL Task targeting your source:
SELECT ISNULL(OBJECTPROPERTY(Object_ID('dbo.theVendorTabl e'), 'IsUserTable')
,0) as TableExists

Then configure the result as an Output Parameter and store it in a Global
Variable

Then when you are going to Drop the table do a SQL Task targeting your
destination, configure the task to take the GV as an input parameter

IF (? =1)
BEGIN
DROP TABLE localtable
END

--
David Lundell
Principal Consultant and Trainer
www.MutuallyBeneficial.com
David (AT) MutuallyBeneficial (DOT) com

"carolus.holman" <carolusholman (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am runnng into a situtation with a vendor who does not load their
database
consistently. Sometimes a table is missing from their db. It is a lookup
table so is not critical. What I want to do is check for the existence of
the
table in the source db, before I drop my local table. My package fails
because this table is not present. I have tried checking it a few
different
ways, however how can I check for soemthing that does not exist, without
my
package failing?



Reply With Quote
  #3  
Old   
carolus.holman
 
Posts: n/a

Default Re: Adding logic to check for existence of soource tables - 06-12-2006 , 09:01 AM



Essentially this is correct and is a great start for me to solve my issue.
However I am transferrig data from an ODBC datasource, mySQL.

I am new to the SSIS package designer and don't fully understand how to set
GV's.

Here are the steps I am doing:

Add a SQL Task
Add a connection manager to the source DB (mySQL)
Edit the SQL Task


Connection Type = ODBC
Connection = mysqldbname
SQLSourceType = Direct input
SQL Statement = SHOW TABLES FROM mySQLDB LIKE 'table_I_AM_Checking'

click on Parameter mapping
Add Parameter (here is where I can't compute)

I set the variable name to User::checkMySQL
Direction Output
Datatype SQL_VARCHAR

Once this is done, I try excuting the package to see if works, I get a
failure. I am not sure if I bind the output of this task to the next task?


The output I get from mySQL is either NULL or th name of the table. i would
think that i could check to see if a row is returned.

Any good resources out there for SSIS packages, the Microsoft Help and BOL
are fairly scant on this subject.




"David Lundell" wrote:

Quote:
Carolus:

If I understand your problem correctly this should work.

Assumption: Source and Destination are SQL Servers

Setup a SQL Task targeting your source:
SELECT ISNULL(OBJECTPROPERTY(Object_ID('dbo.theVendorTabl e'), 'IsUserTable')
,0) as TableExists

Then configure the result as an Output Parameter and store it in a Global
Variable

Then when you are going to Drop the table do a SQL Task targeting your
destination, configure the task to take the GV as an input parameter

IF (? =1)
BEGIN
DROP TABLE localtable
END

--
David Lundell
Principal Consultant and Trainer
www.MutuallyBeneficial.com
David (AT) MutuallyBeneficial (DOT) com

"carolus.holman" <carolusholman (AT) discussions (DOT) microsoft.com> wrote in message
news:45A67804-42FE-4C42-8544-0DA12A6AF317 (AT) microsoft (DOT) com...
I am runnng into a situtation with a vendor who does not load their
database
consistently. Sometimes a table is missing from their db. It is a lookup
table so is not critical. What I want to do is check for the existence of
the
table in the source db, before I drop my local table. My package fails
because this table is not present. I have tried checking it a few
different
ways, however how can I check for soemthing that does not exist, without
my
package failing?




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.