Search code examples
sql-server-2005resultset

Sql Server 2005 Copy Multiple Result Sets


How Can i copy multiple result sets at the same time?

for example if i were to execute the below code:

select 'a'
select 'b'
select 'c'

how can i copy all 3 results so i can then paste them into excel? I tried holding down shift and selecting all 3 result sets but it only copies the last one i select.


Solution

  • Try this:

    select 'a'
    union all
    select 'b'
    union all
    select 'c'
    

    This will return one result set that you can copy and paste wherever you'd like.