Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Columns of second query appears in diff order when use UNION. Expand / Collapse
Author
Message
Posted Wednesday, December 15, 2010 12:12 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:25 AM
Points: 1,500, Visits: 2,519
Hi All,

--- Results of first query

Server AppName Version
Srvr1 App1 6.1.1016
Srvr1 App2 6.1.1033
Srvr1 App3 5.7.216


--- Results of second query
Server AppName Version
Srvr2 App4 12.5



--- Results when I UNION the above 2 queries.
Server AppName Version
Srvr1 App1 6.1.1016
Srvr1 App2 6.1.1033
Srvr1 App3 5.7.216
12.5 Srvr2 App4


Why the last row columns (second query results) comes is diff order



Thanks in Advance.





Post #1034918
Posted Wednesday, December 15, 2010 12:53 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, June 6, 2014 2:18 PM
Points: 843, Visits: 2,559
Hi,

Could you post that query?


__________________________
Allzu viel ist ungesund...
Post #1034930
Posted Wednesday, December 15, 2010 1:11 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:25 AM
Points: 1,500, Visits: 2,519
Thanks for your quick reply.

Problem resolved. First query is Grouped By "AppName"
and second query is Grouped By "Server".
When I made first query to be grouped by "Server, AppName' result is coming properly.

but, I am still not clear why should it make difference based on the group by columns. I dont understand.

Thanks.

Post #1034936
Posted Wednesday, December 15, 2010 7:12 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:29 AM
Points: 6,581, Visits: 8,857
I'd really like to see the query you were running also... from what you've said, this shouldn't be happening. The proof is in the code. I'd be very appreciative if you would post it please.

Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
Post #1035119
Posted Thursday, December 16, 2010 8:40 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:25 AM
Points: 1,500, Visits: 2,519
Hi,
Thanks for your response.

I am sorry that I can't post the query here.
I tried to simulate the issue in test, but couldn't.
But beleive me, it's a strange problem. And one more thing...

When I simply quey using "UNION" this issue occurs.
But when I add "top 10 *" with same query, it just works fine.

Anyways, when I am free, will try to put those records in some dummy tables and simulate the same error so that I can show you the error.

Thanks again.
Post #1035892
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse