sql - OPENQUERY with a variable in a cursor -


How can I return an OpenQuery in SQL Server with a variable for a cursor?

DECLARE curMyCursor for CURSOR EXEC (from 'SELECT * OPERQUERY (SYBASE,' Select * from MyTable WHERE MyPrimaryKey = '' '' '+ @Variable +' '' '' '' '' '')

Open @ ResultCrsr

Open query results

But why do you need a cursor? I'm sure there is a better way of working without it.


Comments