I have the following stored procedure that gets a filename and restores a .bak file, but I keep getting the following error: I definitely know that the filename L:\PracticeManager_db_200707180119.BAK exists on that server .Server: Msg 3201, Level 16, State 2, Line 58Cannot open backup device 'L:\PracticeManager_db_200707180119.BAK'. Device error or device off-line. See the SQL Server error log for more details.Server: Msg 3013, Level 16, State 1, Line 58RESTORE DATABASE is terminating abnormally./*kill all spids! before we start the restore process to gain exclusive access to the db**SPID MUST BE LAUNCHED FROM THE RESTORE SERVER*/SET NOCOUNT ONbegindeclare @killspid varchar(30)declare c_KillOtherSpid cursor forselect 'kill ' + convert(varchar, spid) as spidfrom master..sysprocesseswhere hostname <> '' and hostname <> @@SERVERNAMEand spid <> @@spidopen c_KillOtherSpidfetch next from c_KillOtherSpidinto @killspidwhile @@fetch_status = 0beginexec (@killspid)fetch next from c_KillOtherSpidinto @killspidendclose c_KillOtherSpiddeallocate c_KillOtherSpidend--find the backup file name on productioncreate table #bkupname (filename varchar(50))declare @date varchar(7)declare @cmd varchar(100)set @date = convert(varchar,getdate(),112)set @cmd = 'dir /b \\wmg-millbrook\G$\centricity\backup\PracticeManager_db_' + @date + '*.bak'insert into #bkupnameexec master.dbo.xp_cmdshell @cmdselect top 1 filename into #bkupname1 from #bkupname where filename is not nulldeclare @filename2 varchar(50)select @filename2 = filename from #bkupname1drop table #bkupnamedrop table #bkupname1--select @filename--restore that backupdeclare @restdir varchar(600)set @restdir = 'L:\' + @filename2select @restdirRESTORE DATABASE PracticeManagerFROM DISK = @restdir--update the global.asa file name for the lastupdate dateDECLARE @FileName varchar(50), @bcpCommand varchar(2000)Create Table globalasa (test varchar(250))insert into globalasaselect '<!--==Visual InterDev Generated - startspan==-->' union allselect '<!--METADATA TYPE="TypeLib" NAME="Microsoft XML, v3.0" UUID="{F5078F18-C551-11D3-89B9-0000F81FE221}" VERSION="3.0"-->' union allselect '<!--METADATA TYPE="TypeLib" NAME="Microsoft Scripting Runtime" UUID="{420B2830-E718-11CF-893D-00A0C9054228}" VERSION="1.0"-->' union allselect '<!--METADATA TYPE="TypeLib" NAME="Microsoft ActiveX Data Objects 2.6 Library" UUID="{00000206-0000-0010-8000-00AA006D2EA4}" VERSION="2.6"-->' union allselect '<!--==Visual InterDev Generated - endspan==-->' union allselect '<!-- #include file="version.inc" -->' union allselect '' union allselect '<SCRIPT LANGUAGE=VBScript RUNAT=Server>' union allselect 'Sub Application_OnStart' union allselect ' SetApplicationVersion()' union allselect ' SetApplicationVariables()' union all select '' union allselect ' Dim ConnStr' union allselect ' ConnStr = "provider=SQLOLEDB.1;data source=" & Application("DBServer") _' union allselect ' & ";initial catalog=" & Application("DBName") _' union allselect ' & ";User Id=" & Application("DBUser") _' union allselect ' & ";Password=" & Application("DBPswd") & ";"' union allselect ' Application("DBConnString") = ConnStr' union allselect ' ' union allselect ' Application("PatientExtras_AddOn") = False ' union allselect 'End Sub' union allselect '' union allselect 'Sub Application_OnEnd' union allselect ' Application.Contents.RemoveAll()' union allselect 'End Sub' union allselect '</SCRIPT>' union allselect '<SCRIPT LANGUAGE=VBScript RUNAT=Server>' union allselect ' SUB SetApplicationVariables()' union allselect ' Application("DBServer") = "WMG-PM-REPORTS"' union allselect ' Application("DBName") = "PracticeManager"' union allselect ' Application("DBUser") = "mbcuser"' union allselect ' Application("DBPswd") = "mbcuser"' union allselect ' Application("OnlineHelpURL") = "http://WMG-PM-REPORTS/CentricityPMHelp/"' union allselect ' Application("Caption") = "***REPORT SERVER - CHANGES WILL NOT BE SAVED!!*** LAST UPDATE: ' + convert(varchar(8),getdate(),1) + '"' union allselect ' END SUB' union allselect '</SCRIPT>'SET @FileName = 'C:\Program Files\MILLBROOK\PracticeManager\global.asa'--SET @FileName = REPLACE('c:\authors_'+CONVERT(char(8),GETDATE(),1)+'.txt','/','-')SET @bcpCommand = 'bcp "SELECT * FROM master..globalasa" queryout "'SET @bcpCommand = @bcpCommand + @FileName + '" -U sa -P sa -c'EXEC master..xp_cmdshell @bcpCommanddrop table master..globalasa--done