I have a requirement like,every month we will have a release, we collect the code from the TFS and give it to the DBA ,he use to execute the sql scripts in prod and if any error occurs he will post us the error and we will fix it from backend.But now we got a requirement,all the DML Script should be given to DBA and it should execute at once if any error occurs in between all the dml statements should rollback as of now done and after rectifying the error the same process we have to follow.
Am trying in this way and the dml format will be in this way,
begin tran operat
Print 'inserts into table emp : Begin '
IF EXISTS (SELECT * FROM sys.tables WHERE object_id = OBJECT_ID(N'[emp]'))
insert into commondb.dbo.emp (ename,deptno,emploc) values ('ttt',13,'gurg')
Print 'inserts into table emp : End '
rollback tran operat
error facing ::
Msg 102, Level 15, State 1, Line 13
Incorrect syntax near 'COMMIT'.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'try'.
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near 'catch'.
Can anyone please help me on the same becauz its very urgent to be fixed.