I have an Excel spreadsheet that I want to import select columns into my SQL Server 2008 database table. The wiz didn't offer that option.
Any easy code options?
I have an Excel spreadsheet that I want to import select columns into my SQL Server 2008 database table. The wiz didn't offer that option. Any easy code options? |
||||
|
Once connected to Sql Server 2005 Database, From Object Explorer Window, right click on the database which you want to import table into. Select Tasks -> Import Data. This is a simple tool and allows you to 'map' the incoming data into appropriate table. You can save the scripts to run again when needed. |
|||||||||||||||||
|
Microsoft suggest several methods:
If the wizard (DTS) isn't working (and I think it should) you could try something like this http://www.devasp.net/net/articles/display/771.html which basically suggests doing something like
|
|||||||||||||||||
|
This may sound like the long way around, but you may want to look at using Excel to generate INSERT SQL code that you can past into Query Analyzer to create your table. Works well if you cant use the wizards because the excel file isn't on the server |
|||||||||
|
You could use OPENROWSET, something like:
Just make sure the path is a path on the server, not your local machine. |
|||||||||
|
|
|||||
|
Another option is to use VBA in Excel, and write a macro to parse the spreadsheet data and write it into SQL. One example is here: http://www.ozgrid.com/forum/showthread.php?t=26621&page=1
|
||||
|
By 'the wiz' I'm assuming you're talking about the 'SQL Server Import and Export Wizard'. (I'm also pretty new so I don't understand most questions, much less most answers, but I think I get this one). If so couldn't you take the spreadsheet, or a copy of it, delete the columns you don't want imported and then use the wizard? I've always found the ability to do what I need with it and I'm only on SQL Server 2000 (not sure how other versions differ). Edit: In fact I'm looking at it now and I seem to be able to choose which columns I want to map to which rows in an existing table. On the 'Select Source Tables and Views' screen I check the datasheet I'm using, select the 'Destination' then click the 'Edit...' button. From there you can choose the Excel column and the table column to map it to. |
|||
|
Microsoft Access is another option. You could have a Access database locally on your machine that you import the excel spreadsheets into (wizards available) and link to the the SQL Server database tables via ODBC. You could then design a query in access that appends data from the Excel spreadsheet to the SQL Server Tables. |
|||
|
If you would like a visual tool with Desktop interface including validation .. you may well like this Excel tool. You can also use the tool to create multi user data-edit tasks, or even paste data to SQL server from any source.. How to Validate and Import Excel spreadsheet to SQL Server database: |
|||
|
The import wizard does offer that option. You can either use the option to write your own query for the data to import, or you can use the copy data option and use the "Edit Mappings" button to ignore columns you do not want to import. |
|||||||||||||
|
Excel + SQLCMD + Perl = exceltomssqlinsert and you can use your Excel as frond-end to MSSQL db ... Note the truncate table at the beginning of each generated sql insert file ... |
|||
|
I have used DTS (now known as SQL server Import and Export Wizard). I used the this tutorial which worked great for me even in Sql 2008 and excel 2010 (14.0) I hope this helps -D |
|||
|
The best tool i've ever used is http://tools.perceptus.ca/text-wiz.php?ops=7 Did you try it? |
|||
|
This link will definitely help you to do it quicker.The query to fetch excel data for export to be done for the required columns only. |
|||||
|
I think it will help you |
||||
|
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?