Solved

Merge two spreadsheets based on a common column

Posted on 2008-10-15
5
2,248 Views
Last Modified: 2013-11-05
There has to be a simple way to do this either in Excel or SQL Server 2005.

I have one spreadsheet with customer info including the primary key serv_id, I have another spreadsheet with two columns, serv_id and usage.  I want to add the usage to the first spreadsheet based on the serv_id.  sql something like this.. update table.usage where table.serv_id = spreadsheet.serv_id.

Eventually I'm going to put this in a sql table, not sure if I should do the merge before I put them in sql server or after.  

What's the best way to do this?
0
Comment
Question by:H2Omike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:SpeedFingolf
ID: 22724574
If you open your Excel Files through ADO, you can treat them as tables, and run an UPDATE statement.

You can check this site, where you can find more info. If found it very useful, but I was using Excel files from a VB program. I don't know how are you planning to deal with them. I assume that you could set from SQL Server a connection to Excel files and merge them in a third one.

http://www.xtremevbtalk.com/showthread.php?t=217783
0
 
LVL 2

Expert Comment

by:EruditeMonkey
ID: 22724763
Hi, You could use the vlookup function in excel. It is used to find a matching value from a list and return data from that row. The screenshot below give an example, Ive put both set of data on the same page for simplicity. Once youve done this you would need to copy the data and paste special the resulting data as values to fix it, then clear any #N/A entries using find/replace.
 

vlookup.JPG
0
 
LVL 35

Accepted Solution

by:
David Todd earned 250 total points
ID: 22728058
Hi,

Or you could try a table-join for the original query. Can you post the table definitions and some sample data?

Cheers
  David
0
 

Author Comment

by:H2Omike
ID: 22728122
That is what I did and it seems to have worked.  I did a left join, have to do it for each month usage for 3 years, but it's doing the trick.
0
 
LVL 35

Expert Comment

by:David Todd
ID: 22728595
Hi,

Post your query in another question, as that also sounds painful, and I think I can help optimise it for you.

Cheers
  David

Of course there are others that can help as well :-)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

617 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