How to insert a comma delimited text file into sql database

Hi,

I want the user to uploads a comma delimited text file to my site and i want insert it into the SQL database.

How do i upload the file?
How do i parse the text file?
how and should i convert it to XML file?

Thanks,
YuvalMelAsked:
Who is Participating?
 
HohlovDimaConnect With a Mentor Commented:
Hi,
You can try to do such thing(make select from that set and do what you want)
SELECT a.* FROM OPENROWSET( BULK 'c:\test\values.txt', 
   FORMATFILE = 'c:\test\values.fmt') AS a;

Open in new window

If you only need to ignore duplicate keays you can use option IGNORE.
Best Regards,
Dima.
0
 
HohlovDimaCommented:
Hi,
look at this article i think it will help
http://www.sqlteam.com/article/using-bulk-insert-to-load-a-text-file
Best Regards,
Dima.
0
 
HohlovDimaCommented:
You just need to use Bulk Insert.
0
 
YuvalMelAuthor Commented:
Thanks i did not kow that function.

if i have an error lets say duplicate key i will not know which element is zccount for it right?

and what if i want to know which element causes this, is there a way of knowing that with bulk insert?
0
 
YuvalMelAuthor Commented:
Thanks Dima!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.