473,756 Members | 1,752 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 5432
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
4335
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
3679
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
2550
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
2131
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 has no trouble appending to the database , and then I have to add the auto increment column...
4
2218
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 Import_Records_Err 'Delete the all records in MONTHLY_IMPORTS table 'Call...
4
4810
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
4774
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 structure to give you an idea on where I'm coming from. Thank you so much in advance!!! ...
1
3111
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 same data type in each field. I follow the File>Get External Data>Import path and choose the .xls...
1
1507
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 RLog("fldUnknown")=data(0) 'Site ID RLog("fldAccountName")=data(1) 'Client ID ...
0
9431
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9819
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9689
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7226
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3326
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.