0
我想創建一個批處理文件,它將執行一個將備份數據庫的sql腳本。批處理文件sqlcmd備份數據庫失敗
腳本是這樣的:
USE $(DatabaseName);
DECLARE @DBName varchar(50),
@DateLabel varchar(50),
@FileName varchar(300),
@TodayDate datetime,
@BackupPath varchar(200)
SET @DBName = $(DatabaseName);
SET @BackupPath = $(FolderPath) + '\';
批處理文件輸出這樣的:
G:\Deployments>script_PFBC_ResourceFirstPortal.bat
G:\Deployments>REM ECHO OFF
G:\Deployments>SET outTime=10:41:12.46
G:\Deployments>SET outTime=104112.46
G:\Deployments>SET outTime=10411246
G:\Deployments>SET outPath=PFBCdb_2013_22_01_10411246
G:\Deployments>mkdir PFBCdb_2013_22_01_10411246
G:\Deployments>cd PFBCdb_2013_22_01_10411246
G:\Deployments\PFBCdb_2013_22_01_10411246>SET fullOutPath=G:\Deployments\PFBCdb_
2013_22_01_10411246
G:\Deployments\PFBCdb_2013_22_01_10411246>CD..
G:\Deployments>sqlcmd -i "backup.sql" -v DatabaseName=PFBC_ResourceFirstPortal FolderPath="G:\Deployments\PFBCdb_2013_22_01_10411246"
Msg 102, Level 15, State 1, Server HDCVS-PFBC, Line 21
Incorrect syntax near 'G:'.
批處理文件的最後一行是這樣的:
sqlcmd -i "backup.sql" -v DatabaseName="PFBC_ResourceFirstPortal" FolderPath="%fullOutPath%"
G:驅動器是本地驅動器。我必須做\\ localhostname \ G%\ Deployments \ –