Query for importing data’s from XL to SqlServer DB

Here is a simple query for importing data's from Microsoft Excel sheet to Sql Server database.

Just copy the following code and run in your sql server query window. Before that make XL sheet with the appropriate fields and values and place it in c drive or wherever you wants.

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$]

that's it...


No comments: