Query for importing datas from XL to SqlServer DB

No.of Views613
Bookmarked0 times
Downloads 
Votes0
By  vinothnat   On  15 Feb 2010 22:02:37
Tag : Sql Servers , T-SQL
Query for importing datas from XL to SqlServer DB
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Here is the simple query for importing data's from Excel sheet to SqlServer Data base.

Just use the following query in your sqlserver query window.

{codecitation class="brush:sql; gutter: false;" width="600px"}

INSERT INTO [dbo].[TableName] ([FieldName1]
,[FieldName2]
,[FieldName3]
,[FieldName4]
FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\db.xls;Extended Properties=Excel 8.0')...[SheetName$]

{/codecitation}

Note: Above query support Excel sheet 2003 format, if you need import from the MS Excel 2007  you need change data source like followings.

{codecitationclass="brush: sql; gutter: false;" width="600px"}

Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES";
{/codecitation}

that's is...

...S.VinothkumaR.

 
Sign Up to vote for this article
 
About Author
 
vinothnat
Occupation-Not Provided
Company-Not Provided
Member Type-Junior
Location-Not Provided
Joined date-03 Jun 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top