Home Forums SQL Server 2008 T-SQL (SS2K8) How to use"Union ALL" to join sql queries each containing order by clause RE: How to use"Union ALL" to join sql queries each containing order by clause

  • i don't think so well try this kind of one

    WITH cte AS

    (

    SELECT TOP 10 c.[object_id], c.column_id

    FROM sys.[columns] c

    WHERE c.column_id < 3

    ),cte2 AS

    (

    SELECT TOP 10 c.[object_id], c.column_id

    FROM sys.[columns] c

    WHERE c.column_id < 3

    )

    SELECT ROW_NUMBER() OVER (ORDER BY cte.column_id) AS ID, * FROM cte

    UNION ALL

    SELECT ROW_NUMBER() OVER (ORDER BY cte2.[object_id]) AS ID,* FROM cte2

    Every rule in a world of bits and bytes, can be bend or eventually be broken
    MyBlog About Common dialog control
    A Visualizer for viewing SqlCommand object script [/url]