473,805 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ 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 49822
You can do a query with a UNION as in

Select * from
pay2002.dbo.tab le1
UNION
Select * from
pay2003.dbo.tab le1

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********@hot mail.com> wrote in message
news:b2******** *************** **@posting.goog le.com...
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
3484
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 is that between the delete and append there is a 4 minute window when reports cannot be generated since the tables are empty due to the delete query. Is there method to replace the table with data without having the down time during the delete...
2
5791
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 created a query for the linked database but eventually i need to have this query to be constantly updated and append to another table in the current database. i hope i'm not too vague but i have no idea if i should use an update or an append query....
5
4482
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 error: Deleting data in a linked table is not supported by this ISAM. From what I understand, indexed sequential access method (ISAM) drivers are used to update "non-Microsoft" file formats. So why doesn't Access
2
6577
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 tblClearance. I was thinking of placing the code on the form's BeforeUpdate event so that it will fire whether the user closes the form or attempts to create another record.
1
1398
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 from both agencies, so I'm trying to create a query that provides all active clients/program. I managed to create a union query that did exactly what I wanted, until I realized the data couldn't be changed in the query (bear with me, never had a...
4
4468
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 of motor under one policy. say policy is john2004, so john is owner of 5 cars. now on next year the card has got renew with same conditions(same amounts all), so i need to insert new recocrd via query in new policy is john2005, with same...
5
3536
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 to 1800 stores of a national home improvement chain store. Every week I electronicaly receive an excel spreadsheet "inventory report" with 19,800 rows or records, which I import into my tblSalesData table. The table now has 10 weeks of data or...
2
22864
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 running the query each time is time consuming. Is there a way to create a new table and import the query data into it? What about the next time I run the query, can I just append the new data into the table I just created? Can both of these be...
16
3526
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 renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
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 we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.