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!

Import CSV automatically 1

Status
Not open for further replies.

Hondy

Technical User
Mar 3, 2003
864
GB
Hi - sorry if this is very easy, I want to import a CSV on a daily basis from a location on the network (different subnet but I'm not concerned about that). The file name will change daily as the date gets appended to it, will this matter?

Can someone tell me if this is possible and what I need to do?

Thanks a lot for any any help!
 
Yes.. its possible. You can create a DTS package.
The way to approch this is a combination of Dos commands and DTS Import. Then you can schedule.

Create a folder in your SQL server
IMPORT
sub folder
BAK

C:\IMPORT\BAK

Firts stage the excute the follwoing script\
Go through an follow the logic.
basic dos commands
Step1
Execute Script

declare @data
select @data='del C:\IMPORT\*.csv'
exec master..xp_cmdshell @data
select @data='move \\networkserver\drive\folder\file.csv C:\IMPORT\'
exec master..xp_cmdshell @data
select @data='copy C:\IMPORT\*.CSV C:\IMPORT\BAK\'
exec master..xp_cmdshell @data
select @data='REN C:\IMPORT\*.CSV file.csv'
exec master..xp_cmdshell @data

Step2:
Then you create source and destination, and trans for the data.


<B>Step1===>Step2</B>

If you have any questions let me know.


Dr. Sql
goEdeveloper@yahoo.com
Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top