如何从批处理文件中将命令行参数传递给sql脚本?

时间:2014-08-11 04:15:20

标签: sql sql-server batch-file

我必须从批处理文件中运行SQL脚本,并将参数传递给它。如何从批处理文件中将命令行参数传递给SQL脚本?

我试过像

test.bat的

sqlcmd -b -i "%CD%\Target\Rapiscan Systems\MVXR_Database\Ver 2.2\Database backup Job.sql" -V %1 %2

我通过createprocess

调用了test.bat
szBatchFileName.Format(".\\Target\\Rapiscan Systems\\MVXR_Database\\Ver 2.2\\%s","test.bat c:\back D:\back" );

if( !CreateProcess( NULL,   // No module name (use command line)
    chBatchFileName,// Command line
    NULL,           // Process handle not inheritable
    NULL,           // Thread handle not inheritable
    FALSE,          // Set handle inheritance to FALSE
    0,              // No creation flags
    NULL,           // Use parent's environment block
    NULL,           // Use parent's starting directory 
    &si,            // Pointer to STARTUPINFO structure
    &pi )           // Pointer to PROCESS_INFORMATION structure
    ) 
{
    char* chError = new char[szError.GetLength()+1];
    _tcscpy(chError, szError);
    MVXRInstallationLog(chError);
    AfxMessageBox(chError);
    return FALSE;
}
//Wait till create process complete the job
WaitForSingleObject(pi.hProcess,INFINITE);

我已提交以运行该脚本。请帮助我。

提前致谢。

0 个答案:

没有答案