Tuesday 26 May 2015

MSSQL - How to fix error - incorrect syntax near try expecting conversation

Watch this example on YouTube:


Error
incorrect syntax near try expecting conversation

or
incorrect syntax near catch expecting conversation

to fix:

Replace
BEGIN TRY
    BEGIN TRAN
        SELECT * FROM Table2
        GO
    COMMIT TRAN
END TRY
BEGIN CATCH
    ROLLBACK TRAN
END CATCH

with
BEGIN TRY
    BEGIN TRAN
        SELECT * FROM Table
    COMMIT TRAN
END TRY
BEGIN CATCH
    ROLLBACK TRAN
END CATCH

No comments:

Post a Comment