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 post formdata or http.context.form data from angular 6 to asp.net mvc web api or api using Token based authentication with header

how to post formdata or http.context.form data from angular 6 to asp.net mvc web api or api using Token based authentication with header  ...

Popular Posts