Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a SQL table with column name and no data. i have another excel sheet with column name and data. i need to import the data from excel to sql table. Before that i need to compare sql column names and excel column names. if thats ok then only it needs to be imported.


Please Help me with clear coding. code in c#
Posted
Comments
ssd_coolguy 23-Jun-12 3:59am    
hey.. let us know what you have tried?

For access to the Excel spreadsheet you can use EPPlus[^]

SQL Server Management Objects [^] provides an easy to use API for accessing meta information, such as column names.

The Database.Tables[^] property provides access to the tables in the database, and the Table class has a Columns[^] property that you can use to access each Column[^] of the table in question.

You can then compare the Name[^] of the column against the column name from the Excel spreadsheet.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sandeep Mewara 23-Jun-12 10:01am    
Good one! 5.
Espen Harlinn 23-Jun-12 10:04am    
Thank you, Sandeep :-D
You can either use SQL server Import export wizard which will ask you mapping the excel column to SQL. or use Integration service project[^] to begin with.
 
Share this answer
 
Comments
P.Vinoth 23-Jun-12 4:16am    
Its good Hiren. But i need to do that by coding only. how to do that please help .

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