Is there a mechanic similar to Oracle PL/SQL’s SAVE EXCEPTIONS in Microsoft T-SQL?
Currently I am doing the update using a cursor and it is extremely slow.
The description of SAVE EXCEPTIONS from Oracle’s site:
SAVE EXCEPTIONS allows an UPDATE,
INSERT, or DELETE statement to
continue executing after it issues an
exception. When the statement
finishes, an error is issued to signal
that at least one exception occurred.
Exceptions are collected into an array
that you can examine using
%BULK_EXCEPTIONS after the statement
has executed.
link to the Save exceptions definition:
http://download.oracle.com/docs/cd/E11882_01/timesten.112/e13076/sqlexamples.htm#TTPLS364
If you are importing a large number of records, use an SSIS package ansd send the failed rows to an exception table. If you can;t uses SSIS for some reason, consider cleaning your data before trying to insert it, so that you have no failed rows. For instance delete any records that have a null where you are required to havea value, null out bad dates, etc.
If you are coming from Oracle, you need to stop using cursors and use set-based logic instead. SQL Server does not perform well with cursors.