Validation Stored Procedure

  • Thread starter Thread starter Leon
  • Start date Start date
L

Leon

Is There a better way I could have written the following stored procedure?
Or is my way cool?

Checking: Username, Password, Activation = True

CREATE PROCEDURE GetAuthorization
(
@Username Varchar( 20 ),
@Password Varchar( 16 )
)
AS
DECLARE @AccountID INT
SELECT @AccountID = AccountID
FROM Account
WHERE Username = @username
AND Password = @Password AND Active = 1
IF @AccountID IS NOT NULL
Return @AccountID
ELSE
IF Exists( SELECT Username
FROM Account WHERE Username = @Username)
Return - 3
ELSE
IF Exists( SELECT Username
FROM Account WHERE Username = @Username AND Password = @Password AND
Active = 0 )
Return - 2
ELSE
RETURN - 1
GO
 
Better post this in the ms-sqlserver group. I can see how using nvarchar
instead of varchar might stand you in good stead for future localization :)
 
Back
Top