I am using sql server R2. I have a stored procedure in which I am passing two paramaters as @username varchar(100) and @password varchar(100).
Now, when I create user from my application first time, the password will be NULL.
I want to make a query which return record for matching username and password. The problem is code is passing empty string to stored procedure. I want something that consider or convert empty string to NULL automatically. I already have solution for this using if condition but I want to use single query, not if condition.
EDIT :
Its a simple stored procedure :
CREATE PROCEDURE [dbo].[Pro_TblP]
(
@userName varchar(100),
@password varchar(100)
)
AS
BEGIN
IF (@password ='')
BEGIN
SELECT * FROM TblP
WHERE username = @userName AND password IS NULL AND IsDeleted = 0
END
ELSE
BEGIN
SELECT * FROM TblP
WHERE username = @userName AND password = @password AND IsDeleted = 0
END
END
GO
I want to combine the query in single representation. Don't want the if condition.