As it was pointed out in my comment, you could do the
WHERE (StartDayID between @p0
part of your query by splitting out @p0 into two variables as such:
declare @startDate datetime
declare @endDate datetime
select @startdate = 20110701, @endDate = 20140724
....
WHERE (StartDayID between @startDate and @endDate)
the IN part of your query is a bit trickier, and you could need to split the individual values out into a temp/variable table in order to process them in an IN statement.
You could do this with a split function such as (taken from http://ole.michelsen.dk/blog/split-string-to-table-using-transact-sql/):
CREATE FUNCTION [dbo].[Split]
(
@String NVARCHAR(4000),
@Delimiter NCHAR(1)
)
RETURNS TABLE
AS
RETURN
(
WITH Split(stpos,endpos)
AS(
SELECT 0 AS stpos, CHARINDEX(@Delimiter,@String) AS endpos
UNION ALL
SELECT endpos+1, CHARINDEX(@Delimiter,@String,endpos+1)
FROM Split
WHERE endpos > 0
)
SELECT 'Id' = ROW_NUMBER() OVER (ORDER BY (SELECT 1)),
'Data' = SUBSTRING(@String,stpos,COALESCE(NULLIF(endpos,0),LEN(@String)+1)-stpos)
FROM Split
)
GO
Then in your query where you have:
....
AND BusinessEventCode in @p1),
this would become:
@p1=N'HighVoltage,LowVoltage'
....
AND BusinessEventCode in (SELECT Data FROM dbo.Split(@p1, ','))),
Note that if going this route, you might want to rethink your delimiter, as "," can be common in text, where something like a pipe (|) would potentially be less common.