March 1, 2012 at 3:17 pm
Can anyone think of why a Merge statement would not work within a Try block? I have the errors set to notify if anything happened within the block but cannot figure it out for the life of me.
Long story short: Merge statement will not work in Try block but will outside of try block
March 1, 2012 at 3:22 pm
Please define 'not work'? Throws an error? Gives incorrect results? Converts the server into a washing machine?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 1, 2012 at 3:28 pm
Sorry about the vagueness of "not work". Incorrect results would be the right term here. The Merge statement is used to update documents, or insert new documents within a table. When this merge statement is locked within a try block it seems to miss all of the results it shouldn't be but when run outside the block those documents are then added to the table.
Example:
Table contains:
DocumentOne
DocumentTwo
DocumentThree
Source table for the merge statement has DocumentFour and DocumentFive to add to the Destination table. Inside the Try block the documents in the destination table stay the same but outside of the try block they are added to the destination table. I hope that clears this up.
As I am writing this I am beginning to think this is a bad question and I have missed something elementary.
March 1, 2012 at 3:42 pm
Could you post your code perhaps (or a repo that shows the same behaviour), along with table designs and maybe sample data?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply