Hi,
I have the query below which runs fine with the set parameters
Declare @Region AS varchar(max)
Declare @District AS varchar(max)
Declare @Location AS varchar(max)
Declare @Date AS Varchar(max)
Set @Region = '1'
Set @District = '1'
Set @Location = 'total'
Set @Date = '2013-08-12'
SELECT SUM(CASE
WHEN TEDW_D_TIME_TYPE_1.MILITARY_HOUR_IDNT = 9 THEN VEDW_F_STORE_TRAFFIC_REALTIME.CURR_VISITS
END) AS Hour9
FROM EDW.Logical.VEDW_F_STORE_TRAFFIC_REALTIME
INNER JOIN
EDW.Calendar.TEDW_D_DATE_TYPE_1
ONVEDW_F_STORE_TRAFFIC_REALTIME.DATE_KEY = TEDW_D_DATE_TYPE_1.DATE_KEY
AND TEDW_D_DATE_TYPE_1.DATE_SHORT = @Date
INNER JOIN
EDW.Calendar.TEDW_D_TIME_TYPE_1
ON VEDW_F_STORE_TRAFFIC_REALTIME.TIME_KEY = TEDW_D_TIME_TYPE_1.TIME_KEY
INNER JOIN
EDW.Location.TEDW_D_LOCATION_TYPE_3
ON TEDW_D_LOCATION_TYPE_3.LOCATION_KEY_AS_WAS = VEDW_F_STORE_TRAFFIC_REALTIME.LOCATION_KEY_AS_WAS
AND TEDW_D_DATE_TYPE_1.DATE_KEY BETWEEN TEDW_D_LOCATION_TYPE_3.BEGIN_EFF_DATE_KEY AND TEDW_D_LOCATION_TYPE_3.END_EFF_DATE_KEY
INNER JOIN
EDW.Location.TEDW_D_LOCATION_TYPE_2
ON TEDW_D_LOCATION_TYPE_3.LOCATION_KEY_AS_WAS=TEDW_D_LOCATION_TYPE_2.LOCATION_KEY_AS_WAS
WHERE@Region = 'Total'
OR
@Region <> 'Total' AND
@District ='Total' AND
(TEDW_D_LOCATION_TYPE_2.REGION_NUM = @Region)
OR
@Region <> 'Total' AND
@District <>'Total' AND
@Location = 'Total' AND
TEDW_D_LOCATION_TYPE_2.DISTRICT_NUM = @District
OR
@Region <> 'Total' AND
@District <>'Total' AND
@Location <> 'Total' AND
TEDW_D_LOCATION_TYPE_2.LOCATION_NUM = @Location
but if i change any of the parameters to Lets say @Region = 'Total' then i get the error message saying
"Conversion failed when converting the varchar value 'total' to data type int."
Can someone please help me how to get around this one?
Thanks.