Link to home
Start Free TrialLog in
Avatar of Soluga
Soluga

asked on

SQL Transaction

Hi,

I would like to add a commit and rollback transaction to the code below.
Everything I have tried to so far does not seem to work, I think it is because I have multiple action in the code.

Would be grateful for any help.

Thanks

BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
   
            
                  Insert Into tbl_M04_CompanyRolesHistory
                        (CompanyRoleName, CompanyRoleDescription,
                        CompanyId, LastModifiedBy, HistoryAction, CompanyRoleId)
                        SELECT CompanyRoleName, CompanyRoleDescription,CompanyID, @ModifiedBy, 'Deleted_text', @CompanyRoleID
                        FROM tbl_M04_CompanyRoles
                        Where CompanyRoleID = @CompanyRoleID
                              
                  DELETE dbo.tbl_M04_CompanyRoles
                  Where CompanyRoleID = @CompanyRoleID
                  
                  DELETE tlnk_M04_CompanyRolePermissions
                  WHERE CompanyRoleID = @CompanyRoleID
                  
                  DELETE tlnk_M04_CompanyRoleUsers
                  WHERE CompanyRoleID = @CompanyRoleID
                  
                  SET @ReturnValue = '1'
            
END
Avatar of x-men
x-men
Flag of Portugal image

where and why you want to "add a commit and rollback"?
SOLUTION
Avatar of gazzacrowe
gazzacrowe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Soluga
Soluga

ASKER

Great.

Thanks