Thursday, 18 September 2014

Stored Procedure to activate or deactivate user


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[proc_ActivateDeactivateUser]      
 ( 
 @UserId varchar(50),
 @IsActive bit, 
 @LastModifiedBy int 
 ) 
AS   
       
BEGIN   
   
 Begin Try 

    IF(@IsActive = 1)
        BEGIN
            set @IsActive=0;
        END
    ELSE
        BEGIN
            set @IsActive=1;;
        END

   Update tbl_Users set IsActive=@IsActive,LastModifiedBy = @LastModifiedBy where UserId =@UserId  
 
 End Try   
   
 BEGIN CATCH   
   
     return  '0';   
   
 END CATCH   
   
END

No comments:

Post a Comment