You are here: Re: IF...ELSE error « MsSQL Server « IT news, forums, messages
Re: IF...ELSE error

Posted by Erland Sommarskog on 09/30/43 11:16

(Hannibal111111@hotmail.com) writes:
> I am trying to print out a statement if a record is not found, but I
> keep getting Error 156: incorrect syntax near Else. Here is the stored
> procedure:
>
> CREATE PROCEDURE AddUpdateDoorStyles
>
> (
> @myprojectid varchar(255),
> @doorstyle varchar(255)
> )
>
> AS
>
> IF EXISTS (select *
> from myproject_doorstyles
> where myproject_id = @myprojectid and door_style = @doorstyle)
> ELSE
> Print 'test'


IF ELSE with nothing in between is not permitted in T-SQL, so you need
to put in some dummy statement or change EXISTS to NOT EXISTS:


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация