>>>I'm thinking about it. On the other hand, if I do that, my SQL will become not SQL Server compatible, since I'm joining temp cursor with my real tables.
>>
>>It will be if you use derived table instead of a cursor.
>
>I see. In other words, If we would switch to SQL Server, this procedure would have to be re-written as SP and we would need to use derived tables.
A derived table is a subselect that you are using as a table in outer select. It has nothing to do with using SPs or not.
SELECT * FROM ( SELECT * FROM mytable WHERE ...) dt1 ...
In the example above dt1 is derived table
--sb--