Hi,
You're definitely missing quotes here. You could use
print @query in your stored procedure in order to see how
@query looks like. It looks like this:
Select max(SOLAR_ACTIVE_POWER_G_VAL0) as maxval,datepart(hour,timestamp) as hour from pointdb where convert(varchar,timestamp,101) in(03/07/2014) group by datepart(hour,timestamp)
In order to fix this error, your code near @date should be like this:
in('''+Convert(varchar,@date,101)+''')
Optional information:
There is another way to write dynamic SQL. It might be useful to you. Please take a look at these links:
1.
sp_executesql (Transact-SQL)[
^]
2.
EXEC and sp_executesql – how are they different?[
^]