use print statement to check what value is being passed to the guestid
variable.

--
-Vishal

"mark1961" <mark1961juno.com> wrote in message
news:uDtEaVzRDHA.3236TK2MSFTNGP10.phx.gbl...
>
>
> This query does not work unless I replace the variable in the IF statement
> with a hard coded Guest ID. How can I use a variable in the IF statement?
> Thanks for your help.
>
> Alter Procedure sp_GetNote GuestID int
> As IF (SELECT DATALENGTH(Note) FROM tblGuest WHERE GuestID = GuestID) >
> 100000 /* <==== Must hardcode the Guest ID in this line, GuestID does
not
> work
> BEGIN
> SELECT Substring(Notes, 1, 25)
> FROM tblGuest
> WHERE GuestID = GuestID
> END
> ELSE
> BEGIN
> SELECT Notes
> FROM tblGuest
> WHERE GuestID = GuestID
> END
> RETURN
>
>