Hello guys,
I have a problem with a stored procedure in sql server.
I would like to execute this query
declare @sSQL varchar(255)
SET @sSQL =
'SELECT TOP 1 [value], date, name, [times]
FROM (SELECT value, date, times, name
FROM view
WHERE ValueDate =
(SELECT MAX(date) AS maxdate
FROM view v
WHERE (date BETWEEN ''2006-02-01'' AND ''2006-02-28''))) Newtable
WHERE (name = ''TEST'')
GROUP BY [value], date, [times], name
ORDER BY [times] DESC'
EXEC (@sSQL)
When I execute the query I have no problem but ... when i tried to stored it I have this several problem I do not know why ... something like
Line 4: Incorrect syntax near '='
I would like be able to pass variable on it and create function to store the results in a table.
Please someone could help me on that.
Ina
I have a problem with a stored procedure in sql server.
I would like to execute this query
declare @sSQL varchar(255)
SET @sSQL =
'SELECT TOP 1 [value], date, name, [times]
FROM (SELECT value, date, times, name
FROM view
WHERE ValueDate =
(SELECT MAX(date) AS maxdate
FROM view v
WHERE (date BETWEEN ''2006-02-01'' AND ''2006-02-28''))) Newtable
WHERE (name = ''TEST'')
GROUP BY [value], date, [times], name
ORDER BY [times] DESC'
EXEC (@sSQL)
When I execute the query I have no problem but ... when i tried to stored it I have this several problem I do not know why ... something like
Line 4: Incorrect syntax near '='
I would like be able to pass variable on it and create function to store the results in a table.
Please someone could help me on that.
Ina