-1

I am still new to all of this but I have searched but cannot find this option.

I have an excel file with the data but I cannot get it in my database.

Morpheus
  • 1,616
  • 1
  • 21
  • 31
  • Yep. There's several. – InbetweenWeekends Nov 02 '15 at 17:02
  • I agree that this is a duplicate. Did you search this site? Where have you searched? Here's a link on MSDN: https://msdn.microsoft.com/en-us/library/ms140052(v=sql.105).aspx – Morpheus Nov 02 '15 at 17:41
  • Here is a post I answered a few weeks ago it should help: http://stackoverflow.com/questions/33152772/how-to-restore-data-from-ms-sql-2012-to-ms-sql-2008-using-bak-file-is-this-pos/33153466?noredirect=1#comment54117319_33153466 – Wes Palmer Nov 02 '15 at 18:21

2 Answers2

0

I use this script. Frist save you Excel file as a CSV and then run this:

BULK INSERT TABLENAME
FROM 'C:\FILENAME.csv'
WITH (
      FIELDTERMINATOR = ';',
      FIRSTROW = 1, 
      ROWTERMINATOR = '
'
   );

Hope it helps :)

M. Grue
  • 331
  • 2
  • 11
0

In Management Studio, right click on the target database and choose "Tasks", then "Import Data". In the Import/Export Wizard, click "Next" at the splash screen (if applicable).

On the Data Source screen, choose "Microsoft Excel" and browse to your file and choose the proper version and click "Next"

On the Destination screen, choose "SQL Server Native Client", entering applicable credentials and database, then click "Next"

On the Specify Table screen, click "Next".

On the Select Source Tables, check the worksheets you want to import and optionally type the name of the destination SQL table to which the XLS tab will import - and click "Next".

On the Run Package screen click "Finish", then "Finish" again to to start the import.

With a little luck, the wizard will create the table and start copying rows.

InbetweenWeekends
  • 1,405
  • 3
  • 23
  • 28
  • I always try to get the data out of the native Excel format and into a simple text file before importing. The import wizard makes it fun if the first set of rows contains only numbers for a column followed by rows that include non-numeric values (where this cutoff happens can be set; but you don't really want to set it at the length of your file and force a double scan, do you). The Excel data source has already made the assumption that everything will be numeric and then throw an exception when it reads that text value. – Martin Soles Nov 02 '15 at 17:25
  • Agreed. But the OP didn't provide any info into the contents of the file or if there's only one tab or a dozen. They just asked `how` to do it. – InbetweenWeekends Nov 02 '15 at 17:29