Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, June 5, 2013

Stored Procedure To check whether User already exist or not

CREATE PROCEDURE [dbo].[Proc_User_IsDuplicate]  
 @UserID AS INT, 
 @LoginID AS VARCHAR(100) 
AS 
BEGIN 
 
 IF @UserID >
 BEGIN 
  IF (SELECT COUNT(*) FROM [User] WHERE LoginID = @LoginID AND UserID <> @UserID ) >
   SELECT 1 IsDuplicate 
  ELSE 
   SELECT 0 IsDuplicate 
 END 
 ELSE 
 BEGIN 
  IF (SELECT COUNT(*) FROM [User] WHERE LoginID = @LoginID  AND IsActive =1) >
   SELECT 1 IsDuplicate 
  ELSE 
   SELECT 0 IsDuplicate 
 END 
END

No comments:

Post a Comment