Update/Insert query for import in multiple table

  • I am a newbe to T-SQL programming and DTS.  I require to import data into an SQL database and I really need some help.  Here is what I need to achieve..

    I want to import customer information (name, custID, addrtype, addr1) into an SQL database.  In the SQL, this information is stored in 2 tables. Those 2 tables have a Parent/Shild relationship. 

    Parent table fields: (site, ID, name, CustID)  Key: site, ID (no identity column)

    Child table fields:  (site, ID, AddrType, Addr1)  key: site, ID, addrType (no identity column)

    First of all, I need my procedure to check if the record already exists in the parent table if so, update it, if not insert it.

    If insert, I need to be able to read the last records ID (in the parent table) and increment it, and then insert my row of data (the site field will be static) .  Then I need to insert the corresponding address in the child table (and giving the same ID as the parent)

    How do I write such a Update/insert statement.. Shoud I use DTS to create the workflow??

    Thanks 

  • This was removed by the editor as SPAM

  • Zaza,

    Try this site - lots of helpful information.

    http://www.SQLDTS.com

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply