How to return 1 if username exists and 0 in other case? Here is what I’ve tried.
IF EXISTS (SELECT * FROM [User] WHERE UserName = @UserName and EmailID=@EmailID)
begin
return 1;
end
else
begin
declare @CreatedOn datetime
select @CreatedOn = getdate()
insert into [User](UserName,Password,EmailID,ContactNo,CreatedOn) values(@UserName,@Password,@EmailID,@ContactNo,@CreatedOn)
Maybe you could try this query:
and if user name exists count(*) will be larger then 0