How can I return a OpenQuery in SQL Server including a variable to a cursor?
DECLARE curMyCursor CURSOR FOR EXEC('SELECT * FROM OPENQUERY(SYBASE, ''SELECT * FROM MyTable WHERE MyPrimaryKey=''''' + @Variable + ''''''')')
OPEN @ResultCrsr
How can I return a OpenQuery in SQL Server including a variable to a cursor?
DECLARE curMyCursor CURSOR FOR EXEC('SELECT * FROM OPENQUERY(SYBASE, ''SELECT * FROM MyTable WHERE MyPrimaryKey=''''' + @Variable + ''''''')')
OPEN @ResultCrsr
you don't. put the open query result into a temo table and open a cursor on it.
but why do you need a cursor at all?? i'm sure there's a better way of doing things without it.