How To Create Store proecedure With Sql Transection

How To Create Store proecedure With Sql Transection 


GO
CREATE PROCEDURE dbo.sp_mysp
(
@RoleID int,
@AcessRights varchar(50),
@Name varchar(100),
@IsActive bit,
@IsDeleted bit,
@CreatedBy int,
@ModifiedBy int
)
AS
BEGIN
    BEGIN TRANSACTION;
    SAVE TRANSACTION MySavePoint;
    BEGIN TRY
 insert into UserLogin
 (
 [RoleID] , 
 [AccessRights] ,
 [Name],
 [IsActive] , 
 [IsDeleted] , 
 [CreatedBy] , 
 [CreatedDate], 
 [ModifiedBy] , 
 [ModifiedDate]
 ) 
 values(
 @RoleID ,
 @AcessRights ,
 @Name,
 @IsActive ,
 @IsDeleted ,
 @CreatedBy ,
 getdate() ,
 @ModifiedBy ,
 getdate()
 );
 //Write Table second Insert Query
 END TRY
    BEGIN CATCH
        IF @@TRANCOUNT > 0
        BEGIN
            ROLLBACK TRANSACTION MySavePoint; -- rollback to MySavePoint
        END
    END CATCH
    COMMIT TRANSACTION 
END;
GO



No comments:

Post a comment

Thank You For Your Great Contribution

Featured Post

how to find duplicate item from array using multiple object keys in angular or javascript

 how to find duplicate item from array using multiple object keys There is a way to find based of multiple key find duplicate records in ang...

Popular Posts