SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 T-Sql wild card
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

fralo
Posting Yak Master

149 Posts

Posted - 02/29/2012 :  17:54:44  Show Profile  Reply with Quote
Thanks again. In one of my above posts I show how I'm getting the date.

set @dateString = CONVERT(varchar(8), getdate(),112);
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
36571 Posts

Posted - 02/29/2012 :  18:11:32  Show Profile  Visit tkizer's Homepage  Reply with Quote
Then do this:

set @cadpath = 'c:\cad_' + @dateString + '.bak'

Now use @cadpath for your restore command.

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

Subscribe to my blog
Go to Top of Page

fralo
Posting Yak Master

149 Posts

Posted - 03/01/2012 :  08:33:52  Show Profile  Reply with Quote
Tara, that's not the complete filename. After the date, there comes a randomly generated number. This was the whole reason I started a posting on this. A sample filename would be:

cad_backup_20120301_23948238.bak
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 03/01/2012 :  10:50:25  Show Profile  Reply with Quote
Did you TRY to import the directory to a temp table yet?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

tkizer
Almighty SQL Goddess

USA
36571 Posts

Posted - 03/01/2012 :  13:13:47  Show Profile  Visit tkizer's Homepage  Reply with Quote
quote:
Originally posted by fralo

Tara, that's not the complete filename. After the date, there comes a randomly generated number. This was the whole reason I started a posting on this. A sample filename would be:

cad_backup_20120301_23948238.bak



See you keep changing things, so we are getting confused along the way. If it's a random number after the date, then you need to run xp_cmdshell with the DIR command to get the list. Put that result set into a table and then whatever your logic is, read that table and get the one you want and put that into your variable for the restore. If you can help us identify what your logic is, we can help you with the code.

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

Subscribe to my blog
Go to Top of Page

TimeTraveller
Starting Member

1 Posts

Posted - 04/19/2013 :  08:57:02  Show Profile  Reply with Quote
Hi Fralo, Did you maanage to get this sorted as I am trying to do restore the same way. I am new to SQL and have a loong way to go!

Thanks,



TT
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.23 seconds. Powered By: Snitz Forums 2000