Solved

T-SQL Union queries

Posted on 2008-10-16
2
457 Views
Last Modified: 2012-05-05
Hello,
I have 2 tables in Sql server 2005.
t1 with 9675 record
t2 with 777 record

If i execute a query on t1, let's say q1, it returns 9472 records
and if i execute another one, q2 on t2 i have only 2 records returned.

the 2 queries have the same schema, so i execute them in a union quey, only 9273 records are returned,

Can someone tell me what's happening here, please ????
thanks
0
Comment
Question by:Nyana22
2 Comments
 

Author Comment

by:Nyana22
ID: 22734979
why it's 9273 and not 9472+2 = 9474, so there is some missing records!!
0
 
LVL 12

Accepted Solution

by:
Einstine98 earned 350 total points
ID: 22734981
Use union ALL

select Q1
union All
select Q2

also post your qury for better understanding of your problem and consequently help.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with SQL joins 9 53
Urgent help needed! Unable to to paste in query designer 29 48
Replace Dates in query 14 51
How can i use WITH CTE for checking exist value? 3 45
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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