|
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]
|