Skip to content Skip to sidebar Skip to footer

Catching Multiple Errors In Loop SQL Query

I have the below insert query which selects records from the OriginalData table where everything is of datatype nvarchar(max) and inserts it into the temp table which has specific

Solution 1:

Instead of doing it this way, I handle this by using TRY_PARSE() or TRY_CONVERT() on each column that I am converting to a non-string column.

If you then need to store the validation failures in another table, you can make a second pass getting all the rows that have a non-null value in the source table and a null value in the destination table, and insert those rows into your "failed validation" table.


Post a Comment for "Catching Multiple Errors In Loop SQL Query"