November 11, 2006 at 8:37 am
This will be a basic question to most of you so please bear with me on this.
I have a stored procedure with several insert and update statements. If the first statement fails (for example it might violate the primary key), will the remaining statements still execute? What if the first statement is successful and the second one fails?
What terminology in the SQL Server literature would I look for to help answer these types of questions as well as how to set them up?
Thanks,
Bob
November 11, 2006 at 11:08 am
look for transactions
November 13, 2006 at 12:56 am
it's up to the developer of the sp as to whether it continues when a problem is encountered. As the previous post says, look for transactions... specifically a rollback (or rollbacks depending on how many are involved). Also, typically - an sp might return a 0 on success and an error (ie -1) on fail. So if an update fails, the transaction should roll back and the sp should exit with something like a -1... and if you're really lucky, it would use RaisError to tell you what went wrong...
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply