Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 whats wrong with this SP: If statement

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-16 : 07:13:21
hello
i have a SP, below and getting this error when i add the first 2 lines

Server: Msg 156, Level 15, State 1, Procedure insert_sms_phonebook_1, Line 33
Incorrect syntax near the keyword 'else'.


AS 
If exists (select * from sms_phonebook where phone_number = @phone_number_1 and username = @username_1)
else
INSERT INTO [1newday_com_sql].[dbo].[sms_phonebook]
([username],
[Phone_number],
[Nickname])
select
@username_1,
@Phone_number_1,
@Nickname_1

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-16 : 07:14:39
negate the condition.

If NOT exists (select * from sms_phonebook where phone_number = @phone_number_1 and username = @username_1)
begin
....
end

Go with the flow & have fun! Else fight the flow
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-03-16 : 07:25:32
Now am making progress.

thanks a lot
Go to Top of Page
   

- Advertisement -