473,545 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing comma delimited file

I've been asked to develop a semi-automated type situation where we have a
database table (sql server) and periodically, there will be a comma
delimited file from which we need to import the data, replacing the old.

I naurally know that we can use [truncate tablename] to kill the other data,
but does anyone have any examples of importing a comma delimited file into
SQL Server with ASP?
Aug 29 '05 #1
3 5416
Elmo Watson wrote:
I've been asked to develop a semi-automated type situation where we
have a database table (sql server) and periodically, there will be a
comma delimited file from which we need to import the data, replacing
the old.

I naurally know that we can use [truncate tablename] to kill the
other data, but does anyone have any examples of importing a comma
delimited file into SQL Server with ASP?


Don't do it wit ASP. Use SQL Server's builtin import program: DTS. You can
schedule a DTS package using SQL Agent. A DTS package can check a directory
for the existence of a file, import the file if it's found and delete it.
There is no need to get ASP involved with this process.

See www.sqldts.com for pointers.

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Aug 29 '05 #2
You can connect to a csv file (which can be opened in Excel and which an
Excel file can be converted into) in good form just as you can to a
regular database.

The .csv file needs to be uploaded to the server.

And you can have two recordsets open at the same time.

So I'd suggest going through this recordset one row at a time and within
this loop add a new record to the "real" database's recordset.

And for help connecting to a text file using the Jet OLE DB provider:
http://www.carlprothman.net/Default....viderForTextFi
les

And based on the above link realize that the actual filename does NOT go
in the connection string - rather it goes in the SQL statement
(definitely a little tricky).

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...

<<
I've been asked to develop a semi-automated type situation where we have
a
database table (sql server) and periodically, there will be a comma
delimited file from which we need to import the data, replacing the old.

I naurally know that we can use [truncate tablename] to kill the other
data,
but does anyone have any examples of importing a comma delimited file
into
SQL Server with ASP?


*** Sent via Developersdex http://www.developersdex.com ***
Aug 30 '05 #3

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:eq******** *****@tk2msftng p13.phx.gbl...
Elmo Watson wrote:
I've been asked to develop a semi-automated type situation where we
have a database table (sql server) and periodically, there will be a
comma delimited file from which we need to import the data, replacing
the old.

I naurally know that we can use [truncate tablename] to kill the
other data, but does anyone have any examples of importing a comma
delimited file into SQL Server with ASP?
Don't do it wit ASP. Use SQL Server's builtin import program: DTS. You can
schedule a DTS package using SQL Agent. A DTS package can check a
directory for the existence of a file, import the file if it's found and
delete it. There is no need to get ASP involved with this process.


I totally agree ASP is the wrong place to do this. Here's an alternative to
DTS packages that I've found to be a little more flexible:

Create a subdirectory for misc CSV files -- I intuitively called mine C:\CSV
Create a DSN using the Text driver and the C:\CSV directory
Create a Linked Server in Enterprise Manager, based on the DSN -- I called
mine CSV (catchy names, yeah?)
The linked server lists any files that are in that directory as tables

To access any of the files as a table, the SQL, let's say for a file called
newdata.csv, is:

SELECT * FROM CSV.[c:\csv]..[newdata.csv] newdata

(Note the 4-part name.) You can then join/update/insert using the data in
the text file directly, as if it were a table, without constructing DTS
packages, creating temp tables, etc.

Here's the kinky part: before this will work you need to call
sp_serveroption to set the 'data access' option. The error message that's
returned if you don't almost seems too dumb to be real, something like,
"Server 'ServerName' is not set for data access." The first time I saw that
I thought to myself, "well then what damn good is it?" But it's just
bizarre semantics, apparently not to be taken litteraly. :-)

-Mark
btw, Bob (hope you're well, btw) I recently bought a code signing cert, and
as such I now have a signed version of my HighResTimer object. I also
marked it safe for scripting to make it more usable in client-side script,
and I removed the early interfaces, leaving only one, both-threaded object
interface for it to support. I find I actually use it from time to time (no
pun) it takes a whole bunch of the crap-shoot... In any case I'd be
interested to know whether or not you'd had occasion to use it. If you'd
care to discuss further, let's start a new thread.


See www.sqldts.com for pointers.

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Sep 2 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4309
by: Debbie CD UK | last post by:
I have a large amount of log files from an electronic contro tester that I need to import in to an Access database Unfortunately, they are not comma delimited or fixed with but different fields are on separte lines MO NO 123456 serial no xyz date Obviously , the Access import wizard can not handle this format.
1
3659
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am trying to avoid this extra step. can access read in this file directly into a table as append data? thank you very much for any pointers
8
2527
by: harry | last post by:
Hi Folks: I'm trying to do something that looks simple, but I can't make it work right. It's Access 2000 on a Win2000 computer. I create a database with 5 columbs. The data I need to import is text. The way it's formatted is one line each field, for the 5 fields, then to the next record. The text file looks like this: WPTJ410
1
2120
by: don | last post by:
I'm trying to import a comma delimited text file into MS Access 2002 version - the first column is set for an auto increment primary key and everything works right the first time I import a text file, however when I try to append to this new database table Access always messes up the import - as long as I ieave the auto increment column out it...
4
2199
by: Kathie via AccessMonster.com | last post by:
Hello, I have to import monthly, files that were once *.csv but due to commas in addresses, the interface program was changed to dump tab delimited. Now my code is not finding the files in the folder? The code is below - can anyone help? (The files still are named with the extension of *.csv) Function Import_Records() 'On Error GoTo...
4
4777
by: JustSomeGuy | last post by:
Hi. I have a comma delimited text file that I want to parse. I was going to use fscanf from the C library but as my app is written in C++ I thought I'd use the std io stream library... My Text file looks like: First_Name, Last_Name, ID, Date/Of/Birth<newline> depending on the host the newline is either \n or \r\n
2
4763
by: denisel | last post by:
Hi, We will be conducting surveys through SurveyMonkey online and will be importing the answers by tab delimited or comma delimited file into access. I was wondering if there is specific way to import delimited files into Access or Is there a specific way I should design the survey online so Access can recognize the file? Here is my table...
1
3094
by: puremetal33 | last post by:
I have worked very little with Access and have hit a snag. My task right now is to import the data from a spreadsheet into an existing table in an Access database. I edited the .xls file so that fields are laid out the same L-R and made certain that the data is the same in both the .xls file and the table it is to be imported to have the...
1
1490
by: Anthony1312002 | last post by:
I have a working script that imports a space or tab delimited textfile using the vbTab attribute. But because of an upgrade the file has now become comma delimited. what would I need to change to make this script work with the new file format? strTextLine=objText.Readline data=Split(strTextLine,vbTab) RLog.AddNew ...
0
7464
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7396
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5323
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1874
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.