We help IT Professionals succeed at work.
Get Started

Incorrect syntax near the keyword 'else' - WHY THIS SIMPLE SQL NOT WORKING?

1,388 Views
Last Modified: 2008-01-09
Why am i getting

'incorrect syntax near keyword 'else'

here is my procedure..
--------------------------------

ALTER PROCEDURE UP_New_User (
 
@email varChar(50),
@password varChar(50)
)

AS

BEGIN
      SET NOCOUNT ON;

if (select id from t_contacts where email = @email) is null

declare @property int
declare @images int
declare @facilities int
declare @contact int

      insert into t_contacts (email, password)
      VALUES (@email, @password)
      SELECT @contact = @@IDENTITY
      
      insert into t_images (Image1)
      values (null)
      select @images = @@IDENTITY
      
      insert into t_Facilities (propertyID)
      values (@property)
      SELECT @facilities = @@IDENTITY
      
      insert into t_property (Imageid, Facilitiesid)
      values (@images, @facilities)
      SELECT @property = @@IDENTITY
      
      update t_contacts set propertyid = @property
      where id = @contact

else

select email from t_contacts where email = @email

END

GO
Comment
Watch Question
Top Expert 2006
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE