I am trying to use a select statement with dynamic coulmn names. I have wrapped the Select in a string with a variable holding the column name, and then EXEC'ing it. This works fine on it's own, however I want to use this dynamic Select in a cursor declaration. I get an error about the EXEC statement; I guess you can't use Exec when declaring a cursor FOR ??
SELECT @sql = 'SET QUOTED_IDENTIFIER OFF SELECT PartNum, Description, '+@Model+' FROM PartsTemp'
DECLARE curParts CURSOR FOR
EXEC sp_executesql @sql