Skip to content
Advertisement

SQL Server – Cursor

I am trying to loop through a table using a cursor:

That above returns taskResourceOID and EvUserOID. If I need to output a table with the @TaskOID and the respective taskResourceOID and EvUserOID, what is the best way to do it?

Advertisement

Answer

Use a temporary table or a table variable..

Or even better, don’t use a cursor (this can be performed as a select, but I leave this up to you… Just wanted to show how to use a cursor AND a table as return value)

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement