sql server procedure error

Posted by Mohan on Stack Overflow See other posts from Stack Overflow or by Mohan
Published on 2010-05-29T08:54:39Z Indexed on 2010/05/29 9:02 UTC
Read the original article Hit count: 346

Filed under:
|
CREATE PROCEDURE USP_SEARCH_HOTELS
(
@Text varchar(50),
@Type varchar(40)
)
AS
BEGIN

Declare @Query VARCHAR(60)


IF @Type = 'By Country'
    BEGIN
    SET @Query = 'Hotel.countryName like '+ @Text+'%'
    END
ELSE IF @Type = 'By State'
    BEGIN
    SET @Query = 'HOTEL.stateName like '+ @Text+'%'
    END
ELSE IF @Type='By Property Name'
    BEGIN
    SET @Query='hotel.propertyname like'+ @Text+'%'
    End 
ELSE IF @Type='By Rating'
     BEGIN
     SET @Query='hotel.starRating='+ Cast(@Text as INT)
     END
ELSE IF @Type='By City'
    BEGIN
    SET @Query='hotel.cityName like '+ @Text+'%'
    END

    begin
    select * from hotel,tbl_cust_info
     where
    hotel.agentID=Tbl_Cust_Info.Cust_ID
    and
    (@Query)
    end

END

WHAT IS THE ERROR IN THIS PROCEDURE PLEASE HELP.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2000