0

I need to call ".BAK" files dynamically from a folder in order to restore them.

The folder always contains one ".bak" file, but files vary on a daily basis.

My actual code:

DECLARE @DBNAME VARCHAR(80);
SET @DBNAME = 'SupportServiceDB1'

RESTORE DATABASE [' + @DBNAME + '] FROM  DISK ='D:\SupportService\Backup\*.bak' 
WITH 
MOVE N'Tfs_Warehouse_new' TO N'D:\SQLData\SupportServiceDB1.MDF',
MOVE N'Tfs_Warehouse_new_log' TO N'D:\SQLLog\SupportServiceDB1_1.LDF'
brclz
  • 806
  • 9
  • 23
R.Naresh
  • 1
  • 1
  • 2
    Please rewrite your question (maybe including basic politeness) to give us more details and reformat it... – brclz Sep 06 '16 at 12:02
  • Check out this question on reading files in a directory from TSQL, then use the results for the parameter in you above script. http://stackoverflow.com/questions/11559846/how-to-list-files-inside-a-folder-with-sql-server – Paul Andrew Sep 06 '16 at 12:07
  • I'm Sorry and Thank u so much :) – R.Naresh Sep 06 '16 at 13:29

0 Answers0