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'