Groups | Blog | Home
all groups > sql server odbc > january 2004 >

sql server odbc : Importing Data Throught ASP


Anubis
1/6/2004 11:47:23 PM
Hello,

I've been trying to work with code to import data from a "flat file" (.csv)
into a SQL 2000 table.

I'm not that well versed in SQL and was wondering is it was possible using
OPENROWSET or something similar?

I've tried using OPENROWSET and encountered the error "Ad hoc access to OLE
DB provider 'MSDASQL' has been denied. You must access this provider through
a linked server."

Any help or resources to explain the process would be fantastic.

-Steve

Michael Otey
1/7/2004 9:57:08 PM
If you're trying to upload through an ASP page you don't want to use
OPENROWSET. That's really for accessing OLE DB data sources. For an example
of uploading a file via ASP check out:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasdj01/html/asp0900.asp

Mike O.


[quoted text, click to view]

Anubis
1/7/2004 11:43:29 PM
Hi Mike,

No, actually I wanted to upload data from a flat file (.csv) into a SQL
Database like to following


Flat File (x.csv) contains:

Col1, Col2, Col3
Value 0, Value1, Value 2,
Value 0, Value1, Value 2

Then do a command something like the following:

INSERT INTO dbo.table
SELECT Col1, Col2, Col3
FROM x.csv

Basically I want to open a rowset to insert into a SQL table but I cannot
open the rowset from the .csv source through an ASP command.

Any idea's?

Thanks

-Steve



[quoted text, click to view]

Michael Otey
1/8/2004 11:57:15 AM
If you're running this on the SQL Server system and just want to import the
test file then probably the simplest thing is to use the BULK INSERT
statement something like the following:
BULK INSERT mydb..mytable FROM 'c:\mycsvfile.csv'

WITH (DATAFILETYPE = 'char',FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')

Mike O.


[quoted text, click to view]

AddThis Social Bookmark Button