Solved

Excel Spreadsheet -> SQL Server

Posted on 2007-03-19
4
243 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
[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
  • 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Lag Function DateDiff 2 26
semaphore timeout period has expired 1 33
What is GIS method of Geometry data type? 6 36
SQL Server 2012 and core licensing 5 32
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

752 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