SQL Server Try Catch?
Posted on 2005-03-22
I have a query which inserts data it selects from another table. The table it is inserting to has a unique contraint on one of the fields to keep duplicates out of the table... Problem is that when I run this query and a dup occurs the entire query terminates. Is there a way to tell SQL Server to not stop on this event, and just skip that record and continue?
insert into openers
select * from list99 where id IN (select uid from topeners where listid=13)
Server: Msg 2627, Level 14, State 2, Line 1
Violation of UNIQUE KEY constraint 'IX_openers'. Cannot insert duplicate key in object 'openers'.
The statement has been terminated.
Worth 500 points.