CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: transaction in SQL Server

  1. #1
    Join Date
    Sep 2004

    transaction in SQL Server

    I want two update and one delete statements that should be executed together as one single transaction. Is the following syntax correct? Can the if statement be used within the transaction

    begin tran
    update table1 set f1 = "asfs"
    if @@error <>0
    goto rlbk

    update table2 set f2 = "gfdg"
    if @@error <>0
    goto rlbk

    delete from table1 where f3 = "asdf"
    if @@error <>0
    goto rlbk

    commit tran
    rollback tran

  2. #2
    Join Date
    May 2002
    Colombo,Sri Lanka

    Re: transaction in SQL Server

    Sorry for the delayed reply

    yes there is no problem of using if
    but replace " with '

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)