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!

Not sure how to import CSV from inside a query.

Status
Not open for further replies.

sparkbyte

Technical User
Sep 20, 2002
879
US
I am not sure how to do this but I think it should be possible if using a bit of VBS code inside the script.

What I do now is this.

I have a DTS package (SQL 2k) that imports a CSV and an excel spreadsheet into tables and then I have a SQL script that does a join and select distinct to provide me a list of users and their default printers across our servers.

What I would like to do is eliminate the need for the DTS package and just use the script.

Any ideas?


Thanks

John Fuhrman
Titan Global Services
 
Denise,

Does the user who execute the openrowset script should have bulk insert permission also...
If NO how we do specify in the script to read the all files dynamically from the directory instead of one file(somefile) in the select script..
 
Using T-SQL exclusively, you could read the directory contents into a temporary table, then spin through that table and plug the file name into your OPENROWSET statement, then issue the statement in EXEC().

You could do the same in VBScript, but I'm not sure how you've set up the execution. Is it a scheduled job? Does the user have all necessary permissions, etc., etc.?

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Not NULL-terminated yet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top