SQL Statement Help... Ignore already existing rows

Posted by Funchy on Server Fault See other posts from Server Fault or by Funchy
Published on 2012-04-11T22:23:07Z Indexed on 2012/04/11 23:33 UTC
Read the original article Hit count: 108

Filed under:

I have a table with a foreign key constraint and the command below gives me an error because it's trying to set a value that already in the provider table. How do I update this command to ignore those rows that already exist in the provider table?

UPDATE b SET b.iProvider_PVN = a.POIN FROM dbo.ASPVNTOPOIN_stg a INNER JOIN dbo.Provider b ON a.ASPVN = b.iProvider_PVN AND b.vcProv_Type = 'IPA' LEFT JOIN dbo.Provider c ON a.POIN = c.iProvider_PVN WHERE c.iProvider_PVN IS NULL

© Server Fault or respective owner

Related posts about sql