Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

How to use batch separator inside Begin Try Catch SQL Server

$
0
0

Hello all,

I'm trying to create the SQL Script which needs to revert all the schema changes made if the error comes under a single SQL query. However, I'm trying to join both table and procedure under the same .sql file to run and try catch the error if present. It is working when i only uses the table, but when i try to add the procedure, it has some issue so added GO to separate table and procedure. But I can't able to Combine Begin try with GO statement.

SQL
BEGINTRANSACTIONBEGINTRYGOAlterTABLE[dbo].[Persons_1]([PersonID][int]NULL,[LastName][varchar](255)NULL,[FirstName][varchar](255)NULL,[Address][varchar](255)NULL,[City][varchar](255)NULL)ON[PRIMARY];GOGOAlterTABLE[dbo].[Persons_2]([PersonID][int]NULL,[LastName][varchar](255)NULL,[FirstName][varchar](255)NULL,[Address][varchar](255)NULL,[...

Viewing all articles
Browse latest Browse all 4871

Trending Articles