Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Get the right file name using select @cmd='move

Author  Topic 

soorma
Yak Posting Veteran

52 Posts

Posted - 2009-08-26 : 17:19:32
I have a server where client will FTP some leads everyday. I have to move these leads to a different server. The client will upload the leads with this naming convention YYYYMMDD_test.csv

I have a SP that moves the leads. A dts package that will run everyday.

SELECT @cmd='move \\servername\folder\folder\YYYYMMDD_test.csv \\servername\folder\folder\Export_test.csv'
exec master.dbo.xp_cmdshell @cmd

The question i have how do i get the leads right file for everyday by there naming convention YYYYMMDD_test.csv
If they upload leads like

20091126_test.csv for aug 26 2009
20091127_test.csv for aug 27 2009
When i run the SP i need to get the correct csv file for that day

SELECT @cmd='move \\servername\folder\folder\YYYYMMDD_test.csv \\servername\folder\folder\Export_test.csv'
exec master.dbo.xp_cmdshell @cmd

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-08-26 : 20:16:47
If you are trying to get "today's" file, you can get the date using GetDate() and compose your file name string using the DatePart function.

HTH

=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)
Go to Top of Page

soorma
Yak Posting Veteran

52 Posts

Posted - 2009-08-28 : 12:47:41
Thanks

quote:
Originally posted by Bustaz Kool

If you are trying to get "today's" file, you can get the date using GetDate() and compose your file name string using the DatePart function.

HTH

=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)

Go to Top of Page
   

- Advertisement -