• The best way to do this is by using TRY...CATCH... blocks.

    Read more about them in here: http://msdn.microsoft.com/en-us/library/ms175976(v=sql.100).aspx

    Or search on the internet for more information and come back with any questions that you have.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2