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)
 Rename most recent file in folder

Author  Topic 

killtacularmania
Starting Member

22 Posts

Posted - 2010-04-27 : 13:54:25
I have a batch file that downloads a folder from an sftp site. Is it possible to use SQL to rename the most recent modified file?

NAME DATE MODIFIED
hello042010.zip 4/20/2010
hello042110.zip 4/21/2010
hello042210.zip 4/22/2010 -------This is the file I would want to rename.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-27 : 13:58:52
yup

SELECT NAME, DATEMODIFIED
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY Name ORDER BY DateModified DESC) AS Seq,*
FROM Table
)t
WHERE Seq=1


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -