can I output the records that is not inserted error "ignore/Skip duplicate keys sql server " -
i have insert statement re-create value select tables bring together . select 3000 records when run it. ignore/skip duplicate keys , inserted 2990 rows
insert (col1,col2,col3,col4) (select col1,col2 col3,col4 total outer bring together b on a.id = b.id)
i have inquire how can re-create info without losing record , can output records not inserted
i thing have utilize merge tsql , create ouytput
begin seek --your sql merge here output $action, inserted.*,deleted.*; commit end seek begin grab if @@trancount > 0 rollback select error_number() errornumber ,error_severity() errorseverity ,error_state() errorstate ,error_procedure() errorprocedure ,error_line() errorline ,error_message() errormessage; return; end grab go
sql sql-server transactions
No comments:
Post a Comment