I have the following part within my select statement, which works when I write the dates, but when I send parameters it gives me an error.
This works:
SELECT (...unrelevant info), DATEDIFF(DAY, CASE WHEN Startdate > '14/6/2014' THEN Startdate ELSE '14/6/2014' END, CASE WHEN Enddate < '19/6/2014' THEN Enddate ELSE '19/6/2014' END) + 1 AS AmontOfSelectedDays
This gives me error:
SELECT (...unrelevant info), DATEDIFF(DAY, CASE WHEN Startdate > @from
THEN Startdate ELSE @from END,
CASE WHEN Enddate < @until THEN Enddate ELSE @until END) + 1 AS AmontOfSelectedDays
I do this in my dataset-datatable within visual studio.
When running it within the query builder it gives me the following error:
The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect.Parameter3 ("@from"):
Data type 0F0
(user-defined data type) has an invalid user type specified.
When continuing it gives me the following warning
The @from
variable must be declared.