Solved

T-SQL Union queries

Posted on 2008-10-16
2
454 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Where not exists in same table 3 51
SQL help 5 50
SQL Encryption question 2 50
Following an example - removing duplicate strings 4 48
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

16 Experts available now in Live!

Get 1:1 Help Now