Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rapunzel
Starting Member
1 Post |
Posted - 2012-11-15 : 08:37:50
|
hi, Please help me with a sql code to bulk insert data from excel in a table, without creating a table with predefined column names.Thanks in advance. |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-15 : 09:23:09
|
You can't use BULK INSERT, but you can use OPENROWSET. See this page for documentation and examples: http://msdn.microsoft.com/en-us/library/aa276850(v=sql.80).aspxAdapting from one of the examples on that page, your code would be something like thisSELECT a.* INTO #tmpFROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'c:\MSOffice\Access\Samples\northwind.mdb';'admin';'mypwd', Orders) as a |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-11-15 : 10:15:25
|
if its excel it should beSELECT * INTO #tmpFROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=your full excel sheet path here', [SheetName$]) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|