union on non-select statements?

Posted on 2014-07-23
Last Modified: 2014-07-23
can you doing a union of all records returned by several EXEC statements?
Question by:25112
    LVL 5

    Author Comment

    something like this:

    EXEC master.dbo.xp_readerrorlog 0, 1, 'Error: 823'  
     EXEC master.dbo.xp_readerrorlog 1, 1, 'Error: 823'

    where the 2 EXEC have different parameters.
    LVL 39

    Accepted Solution

    Not really can insert them all in a table and do a select DISTINCT from that table or if you mean UNION ALL just drop the distinct like:

    create table #t1 (c1 sysname, c2 sysname)
    insert into #t1 EXEC master.dbo.xp_readerrorlog 0, 1, 'Error: 823'  
    insert into #t1 EXEC master.dbo.xp_readerrorlog 1, 1, 'Error: 823'

    select DISTINCT * from #t1
    select * from #t1

    Just make sure that your #t1 structure matches the SP record set.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    sql help 5 42
    Select distinct 25 44
    Calculating total percentage per row in Oracle Query 2 23
    Oracle PL/SQL syntax 4 30
    'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now