hello i am learning how to write stored procedures in sql server, i
would like to know what's wrong with the following statement? please
help
the management studio gives me the following error:
Msg 156, Level 15, State 1, Procedure spDealMasterSearch, Line 19
Incorrect syntax near the keyword 'CASE'.
USE [mydatabase]
GO
/****** Object: StoredProcedure [dbo].[spHouseUpdate] Script Date:
04/15/2008 16:02:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[spDealMasterSearch]
@in_Location varchar(50),
@in_HouseType varchar(50),
@in_Size varchar(50),
@in_ExpectedPrice varchar(50)
AS
BEGIN
SELECT dealMasterId From
dealmaster INNER JOIN houses
ON dealmaster.HouseId = houses.HouseId
WHERE
houses.Location = @in_Location AND
houses.HouseType = @in_HouseType AND
houses.Size
CASE
WHEN @in_Size = 'within1000' THEN <= 1000
WHEN @in_Size = 'more1000' THEN 1000
ELSE 0
END AND
houses.expectedPrice
CASE
WHEN @in_ExpectedPrice = 'within5m' THEN <= 5
WHEN @in_ExpectedPrice = 'within10m' THEN <=10
WHEN @in_ExpectedPrice = 'dontcare' THEN 0
ELSE 0
END AND
houses.EntityStatus = 'A' AND
dealmaster.EntityStatus = 'A' AND
dealmaster.expectedPrice <= 5 AND
dealmaster.status = 'offering';
END