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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to import CSV file into SQL Database

Status
Not open for further replies.

JPimp

Technical User
Mar 27, 2007
79
0
0
US
I am not even sure where to begin with this, I need to set up something that will run automatically (as a scheduled task) to check for a CSV file, i.e. *.CSV, if it exists, then copy the contents of the file to a SQL table, then move the CSV file in to a different folder on the network.

I have looked online and find similar requests, but nothing I have seen so far seems to do what I need.

Any insight at all is appreciated.

Thanks,

Kai-What?
 

Do you know your record format of the CSV file?
Is it going to be always the same?
What's your SQL's table(s) structure?

If your CSV file will look like:[tt]
123,abc,John,Texas
987,xys,Barb,Utah
546,ttyter,Jonathan,Ohio[/tt]

and you are trying to move this data in the table defined as:[tt]
MyNumber NUMBER(3)
Abrv VARCHAR(20)
MyField DATE
State VARCHAR(20)
Zip VARCHAR(15)[/tt]

John and Barb will not go into MyField, it is a Date, and what are you going to insert into Zip field?




Have fun.

---- Andy
 
Depending on your version of SQL Server...

With SQL 2000, there is a tool called DTS that exists exactly for this purpose.

In SQL 2005, they made improvements to the tool and renamed is SSIS (SQL Server Integration Services).

Both of the tools can do what you want. Basically, create a package and then schedule it to run.

forum1555
forum961

I encourage you to read through some of the Frequently Asked Questions. Then, if you are still confused, feel free to ask a question in one of those forums.

Good luck.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Take a look at strongm's solution. It should be exactly what you are looking for:

thread222-1213437

You would just need to change your connection string.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top