I am new to SQL Sever and I am trying to create a procedure inside in a transaction as follow:
BEGIN TRY
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
BEGIN TRANSACTION MyTran
--*****************************************************************************
USE [Database]
Create PROCEDURE [dbo].[SP_StoreProcedure] AS
--Some SQL Queries here
Go
Commit TRANSACTION MyTran
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION ;
END CATCH;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
However I get these errors:
Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'PROCEDURE'.Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'BEGIN'.Msg 102, Level 15, State 1, Line 14
Incorrect syntax near 'END'.
If this can not be done in SQL Server what is a workaround?