SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
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  

rapunzel
Starting Member

1 Posts

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

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

sunitabeck
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

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

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

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


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.05 seconds. Powered By: Snitz Forums 2000