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 2008 Forums
 SSIS and Import/Export (2008)
 Getting the latest file name from a folder

Author  Topic 

mani99
Starting Member

13 Posts

Posted - 2011-08-15 : 13:05:16
Hi,

I hope someone can help me with this problem. I need to restore a database back up each day and need to create a script which puts the file name of the latest back up into a variable.

For example, the file name could be <name>+<datestamp>.bak, I need the script to put the complete name of the latest back up into a variable.

I hope there is a straight forward way of doing this, although I cant seem to find a solution.

Thanks in advance.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-15 : 13:09:48
http://weblogs.sqlteam.com/tarad/archive/2009/02/25/How-to-refresh-a-SQL-Server-database-automatically.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mani99
Starting Member

13 Posts

Posted - 2011-08-15 : 14:04:48
Thanks for the reply. Not sure that's quite what I need. I just need to get the name of the file into a variable in SSIS which I can then use to perform certain tasks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-15 : 14:12:05
There's no reason to reinvent the wheel. If you want to though, you can download my code and see the coding that I used to get the latest full backup. It's all in there.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -