SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 bulk insert
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 11/15/2012 :  08:37:50  Show Profile  Reply with Quote
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.

Edited by - rapunzel on 11/15/2012 08:39:54

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/15/2012 :  09:23:09  Show Profile  Reply with Quote
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).aspx

Adapting from one of the examples on that page, your code would be something like this

SELECT a.* INTO #tmp
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
   'c:\MSOffice\Access\Samples\northwind.mdb';'admin';'mypwd', Orders) as a
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 11/15/2012 :  10:15:25  Show Profile  Reply with Quote
if its excel it should be

FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=your full excel sheet path here', [SheetName$])

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000