Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 from xml source to sql table-if record is not ther

Author  Topic 

sarahmfr
Posting Yak Master

214 Posts

Posted - 2011-07-24 : 01:22:41
I would like to import from xml source to sql table but only if the record is not in the table already.
I have an xml source I would like to import to a table in sql but only if the record does not already exists in the table
example xml source has record1,record2 the table has record 2
so only import record 1

I tried to connect the xml source file to oledb using oledb command as a transformation and entered a merge sql command but was not successfull

sarah

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-24 : 01:49:51
did you try OPENROWSET BULK?

see

http://msdn.microsoft.com/en-us/library/ms191184.aspx

you just need to include an additional where clause like

WHERE NOT EXISTS(SELECT 1 FROM table WHERE PK= t.PK)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sarahmfr
Posting Yak Master

214 Posts

Posted - 2011-08-06 : 17:15:26
Thanks

sarah
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-08 : 04:34:47
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -