Solved

Excel Spreadsheet -> SQL Server

Posted on 2007-03-19
4
233 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
ID: 18747332
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
ID: 18747825
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
ID: 18747857
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
ID: 18748018
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

911 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

21 Experts available now in Live!

Get 1:1 Help Now