Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Transactions problem Expand / Collapse
Author
Message
Posted Wednesday, May 7, 2014 5:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 26, 2014 1:25 AM
Points: 1, Visits: 39
Hi,

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 try
begin tran operat

Print 'inserts into table emp : Begin '

BEGIN TRANSACTION
IF EXISTS (SELECT * FROM sys.tables WHERE object_id = OBJECT_ID(N'[emp]'))
BEGIN
insert into commondb.dbo.emp (ename,deptno,emploc) values ('ttt',13,'gurg')

END

COMMIT
GO
Print 'inserts into table emp : End '

end try

begin catch
rollback tran operat
end catch


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.
Post #1568392
Posted Wednesday, May 7, 2014 5:41 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:52 AM
Points: 6,872, Visits: 14,185
Remove the batch separator.

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1568396
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse