Question : How to clear @@error or general error flag in T-SQL

Hello,

I have a script that inserts some data into a table.  Occasionally, source data is duplicated in error, causing an insert to fail and setting the @@error flag.

Is there a way I can clear this error so that when the procedure finishes, it doesn't think there were any errors?

Thanks

Answer : How to clear @@error or general error flag in T-SQL

>The procedure reads individual records from a file and inserts them into a database table (depending on the record type).  It basically looks like this

well, just avoid the error.
1:
2:
3:
insert into mytable_tb (columnlist) 
select valuelist 
where not exists ( select null from mytable_tb where keyfield = keyvalue ) ;
Random Solutions  
 
programming4us programming4us