Question about Trasnaction

  • Hi All,

    I want to know for my clarity that does BEGIN TRAN works for the Dynamic SQL executed through EXEC and Sp_ExecuteSQL

    secondly if i put a transaction on as SP

    e.g.

    BEGIN TRAN

    EXEC sp_sample

    IF @@Error <> 0

    ROLLBACK TRAN

    ELSE

    COMMIT TRAN

    will the transaction be aplied on code inside SP mean i some error occurs inside SP then it gets roll backed. according ot my understading transaction should work in both

    cases as the code is bound inside the transaction.

    Waiting for reply.

    Regards,

    Affan

  • Please do not cross post. As for the answer to your question, it should be. To be absolutely sure you get the desired results set up a test scenario in a copy of the database or similar setup with sample data and verify what you are doing does cause the desired effect. But I setup a test scenario with Dynamic SQL and the TRANSACTION occurred as expected.

  • Thanks Antares and sorry for the cross post as i thought different people are subscribed to different forums.

  • We all agree that most everyone uses the Active Threads link at the top right corner. Common mistake thou.

  • One more question related to index that

    what are the best guidelines and practices for creating indexes.

    Regards,

    Affan

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply