Error handling in SQL SERVER (try Catch) _ Database other

Source: Internet
Author: User
Tags error handling try catch
BEGIN TRY
......
End TRY
BEGIN CATCH
......
End CATCH.
In addition, the WITH statement, if there are other SQL statements before it, should be preceded by the end of the SQL statement with a semicolon ";". For example, in this try catch, you should add a ";" in the front, as follows:
BEGIN TRY

With W as (
SELECT F1,F2,F3
, Row_number () over (order by Id DESC) as ROW
from [T1]
WHERE code= @Code
)
INSERT into [T2] (
F1,f2,f3
SELECT F1,F2,F3
From W WHERE row>100;
End TRY
BEGIN CATCH
End CATCH;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.