DECLARE @sql varchar(8000)
SET @sql = 'DECLARE mycursor CURSOR FOR select * from filename'
EXEC (@sql)
>I am trying to build my select statement into a variable
>declare @query varchar(8000)
>set @query='select * from filename'
>when I try to execute my declare cursor
>declare cursor for @query
>I get an error 'incorrect syntax near @query'
>
>does SQL server allow for creating a cursor based on a select statement
>built into a variable ? and if so what am I doing wrong ?
--sb--