• You;re really making us work over here...

    I tried polishing up the SQL you provided so it would run on SQL Server but it's not even close. Syntax errors everywhere, mis-aligned columns on the insert, constraints reffing non-existent columns.

    Try again?

    Oracle code is fine, we can easily switch it to run on SQL Server and we can write ANSI-standard SELECT statements that will run on both.

    PS ...oh yeah, and this time, expected results would be nice, and show us what you have tried 😉

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato