I'm implement if else in stored procedure with and oprator .
If both Conditions are true the if statement should return 1 else -1.
here username and email should not be duplicate please review query below.
alter proc spUserdetailss
@name Nvarchar(50),
@passwords Nvarchar(100),
@emailadd Nvarchar(50),
@Gender nvarchar(50)
as
begin
declare @Ucount int
declare @Ecount int
declare @returncode int
select @Ucount = count(Username), @Ecount= Count(Email)
from userdata
where Username=@nameUsername = @name and Email=@emailadd
Email = @emailadd
if @Ucount > 0 and @Ecount >0
Begin
set @returncode =-1
end
else
begin
set @returncode = 1
insert into userdata
values(@name, @passwords, @emailadd, @Gender)
end
select @returncode as ReturnValue
end