Let’s say I have an SQL statement that’s syntactically and semantically correct so it executes.
In Management Studio (or any other query tool) how can I test SQL statements, and if I notice that they broke something, rollback (in a separate query?)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easisest thing to do is to wrap your code in a transaction, and then execute each batch of T-SQL code line by line.
For example,
If you want to incorporate error handling you can do so by using a TRY…CATCH BLOCK. Should an error occur you can then rollback the tranasction within the catch block.
For example:
See the following link for more details.
http://msdn.microsoft.com/en-us/library/ms175976.aspx