i tried to insert data in database using stored procedure but according to some condition. for example if data is already exists in database the the stored procedure should not be executed. i am doing the following code but it return 0 every time rather then i want. What can i do
ALTER PROCEDURE dbo.SaveUser
(
@cid int,
@firstname varchar(20),
@lastname varchar(20),
@dob datetime,
@gender varchar(20),
@add varchar(100),
@email varchar(40),
@quali varchar(20),
@yop varchar(15),
@exp varchar(10),
@pass varchar(20)
)
AS
declare @result int
if EXISTS( select Email_ID from Registration where Email_ID=@email )
begin
set @result=4;
return @result;
end
else
begin
insert into Registration values(@cid, @firstname, @lastname, @dob, @gender, @add, @email, @quali, @yop, @exp, @pass );
set @result =0;
return @result;
end