[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

union on non-select statements?

can you doing a union of all records returned by several EXEC statements?
0
25112
Asked:
25112
1 Solution
 
25112Author Commented:
something like this:

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

where the 2 EXEC have different parameters.
0
 
lcohanDatabase AnalystCommented:
Not really but...you 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
--OR...
select * from #t1

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

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now