General information
Forum:
Microsoft SQL Server
Title:
How to debug runtime insert/update failures?
I am wondering if there is a way to effectively debug a failing (at runtime - not at compile time) transact sql insert or update statement that updates multiple (possibly thousands or hundreds of thousands) of rows, such that one can know at exactly what point, or what row it failed on. For example in an 'insert into from' statement such as below:
/* update soshiph */
insert into ms501.dbo.soshiph
() from ms501.dbo.arinvc
I am getting the error that SQL Server can't insert a duplicate primary key.
I can go to the source table - arinvc - and run a dupe checking routine - and eliminate the dupes, and run again. But what I am wondering is whether I can determine the specific key value that it is failing on - is there some buffered value or values for the row sql server is attempting to operate on, in a variable. I don't know how to use the sql debugger - would this help?
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only