473,473 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL Query - Append data from two tables

I need to run a query which will pull data from two tables and append
it as one when it displays the result. The data are in two tables. But
the result set will be identical in terms of number of columns. I want
to display it one set below the other.

This is for pay history. From 2003 we have a new payroll system. Till
2002 we used to have a different system. But I need to run a query
which will pull the data for an employee for the last one year. So the
information is spread out between these two tables. Both these tables
are in SQL Server databases.

I want to write a Stored Procedure. I can use Shape/Append but I think
it doesnt work on QA/Stored Proc. It needs an OLEDB.

How can I write the query. I dont want to use temporary tables and do
inserts.

Thanks

GIRISH
Jul 20 '05 #1
1 49797
You can do a query with a UNION as in

Select * from
pay2002.dbo.table1
UNION
Select * from
pay2003.dbo.table1

This query assumes you that 2 separate databases like most payroll databases
have. This will produce one result set with data from 2 years.

"Girish" <ka********@hotmail.com> wrote in message
news:b2*************************@posting.google.co m...
I need to run a query which will pull data from two tables and append
it as one when it displays the result. The data are in two tables. But
the result set will be identical in terms of number of columns. I want
to display it one set below the other.

This is for pay history. From 2003 we have a new payroll system. Till
2002 we used to have a different system. But I need to run a query
which will pull the data for an employee for the last one year. So the
information is spread out between these two tables. Both these tables
are in SQL Server databases.

I want to write a Stored Procedure. I can use Shape/Append but I think
it doesnt work on QA/Stored Proc. It needs an OLEDB.

How can I write the query. I dont want to use temporary tables and do
inserts.

Thanks

GIRISH

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Greg | last post by:
I run some reports from the web that is connected to an Access database. I run a macro every 25 minutes that deletes the tables and then appends data to the tables with fresh data. The issue I have...
2
by: JMCN | last post by:
hi i need some advice on whether if it would be better to use an append query or an update query. here is the situation, i have linked another database table to my current database. then i...
5
by: deko | last post by:
How to run action query against linked table? I have an Access 2003 mdb with an Excel 2003 Workbook as a linked table. When I attempt to run an action query against the linked table I get this...
2
by: Paul Wagstaff | last post by:
Hi there I have 2 tables: tblAccuracy & tblClearance Users add new records to tblAccuracy using frmRegister. Under specific conditions I need to append the current record from frmRegister into...
1
by: Cami Huysman | last post by:
Okay, long story semi-short. Two tables for two different agencies and two different sets of clients. All the fields are identical. Two programs (diff funding streams) have different clients...
4
by: Shahzad | last post by:
dear respected gurus, I would like to knew how to apply append,insert query for a self table where no primary keys issues. i do have problem say there are 5 rows of single record, this is data...
5
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
2
by: John T Ingato | last post by:
If I run a query that calculates the sales data for all the inventory level in a table, how do I go about saving that sales data into a permanent table? I plan I using this sales data often, and...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.