wholee1
wholee1

Reputation: 1501

SQL Server 2008 import excel file

How can I import excel file? I don't have Visual Studio 2008, I have just Visual Web Developer 2008 Express. How can I import excel file to the table on SQL Server

Upvotes: 0

Views: 2016

Answers (2)

frenchie
frenchie

Reputation: 51927

Here's a super simple solution that may work depending on how you're setup: copy-paste! For this to work, you must have your tables set up in SQL server. I recommend you download SQL Server Express; it'll be easier this way.

Look at the excel file, determine which columns you want to import. Create a table in SQL server with the same number of columns. Choose the appropriate datatype. If in doubt, leave everything to a varchar(MAX) for the first try and make sure to "Allow nulls" initially too. You can always come back, delete the table and redo these steps with an adjusted datatypes once you have it working once.

Select the cells of the columns you want to import and press copy. Go to the table and choose "edit top 200 rows". They should be blank. Click the top left area of the table (like in excel where you can select the entire sheet). Press paste.

Voila.

Upvotes: 0

Silx
Silx

Reputation: 2691

Depend of your needs you can do it manually both from Managment Studio Express 2008 (how) that should be installed with your instance or can be added (it's free) or running T-SQL query (how)

If you want write a code you should choose your favorite database API (EF, ADO.NET) and iterate thru excel file and insert rows into your table.

Upvotes: 2

Related Questions