Hi Experts,
i am writting a stored procedure in sql server 7. Its a simple stored
procedure
It is my first stored procedure.
I want insert a record in table if the primary key field user id
already does not exists. if it exists SP should pass 0 as output else
if insert is successfull it should pass 1 to calling sp.
But following SP raising an ERRor" Incorrect Syntax near 'GO'
help
It is as follows
Create Procedure Sp_FillUserDetails
@UserId varchar(50),
@Password varchar(50),
@DOB DateTime,
@Gender varchar(6),
@Address varchar(250),
@City varchar(50),
@State varchar(20),
@Country varchar(20),
@ZIp varchar(15),
@Phone1 varchar(15),
@Mobile varchar(15),
@Email varchar(100),
@CCName varchar(25),
@CCno varchar(25),
@ExipiryDate DateTime,
@Question varchar(60),
@Answer varchar(50),
@Result int output
AS
If exists(Select * from Users where userid=@UserID)
set @Result=0
Else
Insert into Users (Userid, Password, dob, Gender, Address, City,
State, Country, Zipcode,Phone1, Mobile, EmailID, CCname, CCno,
expirydate, Question, Answer) values
(@UserId, @Password ,@DOB ,@Gender ,@Address ,@City ,@State ,@Country
,@ZIp ,@Phone1 ,@Mobile,@Email ,@CCName ,@CCno ,@ExipiryDate
,@Question ,@Answer)
set @result=0
GO