I'm trying to create a batch file that will execute a sql script which will backup a database.
The script looks like this:
USE $(DatabaseName);
DECLARE @DBName varchar(50),
@DateLabel varchar(50),
@FileName varchar(300),
@TodayDate datetime,
@BackupPath varchar(200)
SET @DBName = $(DatabaseName);
SET @BackupPath = $(FolderPath) + '\';
The batch file outputs this:
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:'.
The last line of the batch file looks like this:
sqlcmd -i "backup.sql" -v DatabaseName="PFBC_ResourceFirstPortal" FolderPath="%fullOutPath%"