Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dears...

I have 2 csv files. 1 contains 10 fields and other contains 8 fields. I have to insert this contents to two seperate tables. Please help me on this.

Thanx in advance
Saju
Posted

You could use SSIS for this, or you could do it in code.

Either way, you must somehow map the fields in your csv to columns in your database - there is no "generic method" that can do this for you.
 
Share this answer
 
There is a nice article on codeproject on this
Importing CSV Data and saving it in database[^]
 
Share this answer
 
SQLBulkCopy should give you an opportunity to do this - see here[^].
 
Share this answer
 
You can use T-SQL, try this:

bulk insert [dbo].[Courses]
from 'C:\Courses.csv'
with (fieldterminator = ',', rowterminator = '\n')
go



For more info, check this post: Importing a CSV File into SQL Server
 
Share this answer
 

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