Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import text file to SQL server... via ASP

Status
Not open for further replies.

kenhutchings

Programmer
Jan 11, 2005
32
GB
Hi all

WHat I want to do is allow a user to upload a txt file to the server and then import the contents of the text file (csv format) into the SQL Server - I have already sorted the upload but I am having massive amounts of difficulty passing the values into the SQL server table. I dont really want to do it line by line using a sproc so if anyone has an idea / solution I would be most greatful

Many, many thanks in advance
Ken

Sleepless coder in the North of England
 
If you want to use stored proc please use bulk insert (bcp) with format file. If you want to pre-process the data from csv insert data to a tempdb or staging table. you can also use bcp/trigger combo. Let me know if this answers your question.

Thanks
sqlhelp.blogspot.com
 
you could use a StreamReader on the text file, and then read character by character, line by line, or to the end of file as a String and insert it with ADODB.
 
You also can use the bulk insert command to import the text file via a stored procedure. You simply pass the name of the file to import to the procedure, then use the variable within the bulk insert. Look up bulk insert in books online.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top