Avatar of karthik80c
karthik80c
Flag for United States of America asked on

Is there any Easy way to copy CSV to SQL Server using C#

Hi Experts ,

Lot of Internet solutions are trying to create a Data table first and map the column SQL bulk instances and try to import the CSV . What if i have 30 to 40 columns . Do i need to all those columns in data table and SQL bulk copy Instances. Is there any other easy way on this
Microsoft SQL ServerMicrosoft SQL Server 2005C#ASP.NET

Avatar of undefined
Last Comment
karthik80c

8/22/2022 - Mon
Vitor Montalvão

You don't need to reinvent the wheel. SQL Server has a bulk copy utility called BCP. It's an .exe file so it can be called from a C# program. Check the examples in the link, they are with .csv.
Or you can execute BULK INSERT command from the database. There's also a .csv example from the link.
ASKER CERTIFIED SOLUTION
Zberteoc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
karthik80c

ASKER
Thanks For ur suggestions Experts
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes