I get error:
Conversion failed when converting date and/or time from character string.
I call the stored procedure like this:
var result = (from x in db.spStoredProc(sStart, sEnd) select x).ToList();
where sStart and sEnd are strings with this value:
sStart = "CONVERT(date,GETDATE())"
and
sEnd = "DATEADD(d,1,CONVERT(date,GETDATE()))"
The stored procedure has two parameters of type varchar(max)
In the stored procedure I make left join and I use them like this:
where date_expire >= @sStartSQL AND date_expire < @sEndSQL
Why do I get the error?
You can only pass literals as parameters. So SQL Server literally tries to cast this to date:
Instead, pass:
as parameter.