I’m generating a large script to do a bunch of inserts and updates. When I run it I get some errors, but the error messages don’t let me pinpoint the problem – the line numbers are since the last “GO”, so I can’t find the right line.
I’d like to add calls to my script to a function in T-SQL that will just write to the results window, so I’d have a better idea where the error occurs.
You can simply use PRINT in the pleces that you suspect can cause problems
e.g.
You can also wrap your code into block of TRY CATCH statements and throw custom errors or print error messages if something goes wrong