Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am Mohan Kumar from Chennai.

I have doubt for convert the excel file into database table.
Please can anyone who knows how to do this reply to me.

Mohan
Posted
Updated 6-Apr-11 22:48pm
v2
Comments
Dalek Dave 7-Apr-11 4:48am    
Edited for Grammar and Syntax.

try this link

Link 1:[^]

Link 2:[^]
 
Share this answer
 
Comments
Mohankumar.Engain 8-Apr-11 11:03am    
hi friend i know but simply confusing... if u have C# code please sent me i clarify and learn...

by mohan
You have two ways of doing it.

1. The easy and simple way i.e to use the Import Wizard provided by the SQL Server.

2. Use the OPENROWSET command.

SQL
INSERT INTO [tableName] ([C1], [C2], [C3], [C4])  
SELECT DB.[C1], DB.[C2], DB.[C3], DB.[C4] 
FROM OPENROWSET  ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\testDB.xls;HDR=YES', 'select * from [Sheet1$]') AS DB; 



I personally prefer the second method. Though it looks little complecated its the best way of doing it.

BR//
Harsha Narayana
 
Share this answer
 
Comments
Mohankumar.Engain 8-Apr-11 11:04am    
thank u friend i ll rejoin u bye with another code...

by mohan

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900