Solved

Excel Spreadsheet -> SQL Server

Posted on 2007-03-19
4
232 Views
Last Modified: 2012-06-27
I have an excel spreadsheet that I need to insert into two database tables.

Each row in the spreadsheet signals a new record, but there is a catch. Columns A to J need to go into one table, while columns K to O need to go into another table but there needs to be a link/key created between the two tables so there's a link.

Any ideas anyone?
0
Comment
Question by:PeterErhard
  • 2
4 Comments
 
LVL 28

Expert Comment

by:imran_fast
Comment Utility
Do it using a staging table first move all the data into one stagetable inside sql server and then use sql commands to move it to repective two tables.
0
 
LVL 16

Expert Comment

by:rboyd56
Comment Utility
In the Exce1 worksheet create a deined range from A to J and another one from K to 0.  The when you do the import you specify the range as the table name in the Excel worksheet.  

As far as the link goes..is there a common column in each of the ranges that you can link on. IN other words does each of the ranges have a column that has the same data as the other range. Without that I do not see how you can link the data and have it consistently correct.
0
 

Author Comment

by:PeterErhard
Comment Utility
Thanks for your response. Re your first paragraph, how did I specify the range, when I go and query the spreadsheet?

Unfortnaltey, no there isn't a link between the two, they're just on the same row.
0
 
LVL 16

Accepted Solution

by:
rboyd56 earned 500 total points
Comment Utility
In the worksheet in Excel, select the range A to J (all columns and rows that you want imported). The go to Insert - Define - Name. Type in the name that you want ot use and click OK.

Then to import the worksheet:

Create the tables with the proper column definitions as the range in Excel, except make the first column in the tables an identity range.
Use the Import Wizard to import the Excel worksheets. Use a select query and use select * from <defined range>.
Pick the table to import into click the ellipse (...) and check enable identity insert

Finish the wiard and run the package
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 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

18 Experts available now in Live!

Get 1:1 Help Now