:T02
cls
echo Qualifiers will be installed next with names of
echo Q_AutoFax_CC_1
echo Q_AutoFax_CC_2
echo Q_AutoFax_CC_3
echo Q_AutoFax_CC_4
echo Q_AutoFax_CC_5
pause
cls
If Exist "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\bcp.exe" cd "C:\Program Files\Microsoft SQL Server\100\Tools\Binn"
If Exist "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe" cd "C:\Program Files\Microsoft SQL Server\90\Tools\Binn"
If Exist "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\bcp.exe" cd "C:\Program Files\Microsoft SQL Server\80\Tools\Binn"
sqlcmd /U eiw_admin /P eiw_admin /d cabinet /S . /Q
"declare @q int
select @q = 1
While @q < 6
Begin
Insert into cabinet..qualifiers
select 'HL7', 'Q_AutoFax_CC_'+ convert(varchar(2),@q),
'%Physician_Code'+ convert(varchar(2),@q)+'% == (NULL) || %Physician_Code'+ convert(varchar(2),@q)+'% == (BLANK)', 'R'
select @q = @q + 1
End"
pause
cls
我通常只运行:
declare @q int
select @q = 1
While @q < 6
Begin
Insert into cabinet..qualifiers
select 'HL7', 'Q_AutoFax_CC_'+ convert(varchar(2),@q),
'%Physician_Code'+ convert(varchar(2),@q)+'% == (NULL) || %Physician_Code'+ convert(varchar(2),@q)+'% == (BLANK)', 'R'
select @q = @q + 1
End
来自SQL的它运行得很好...我之前在批处理文件中使用过SQL命令...是否有一些不同需要为此进行的操作,因为它是循环而不是通用命令?该文件正在从数据库服务器运行,我收到一个错误:
Sqlcmd: '-Q': Missing argument. Enter '-?' for help. ' "declare @q int' is not recognized as an internal or external command, operable program or batch file
.....同样的选择,开始,插入和选择....等
我想如果你想要运行SQLCMD,你只需要用单引号命令,这不正确吗?
答案 0 :(得分:1)
批处理文件中的SQL语句应与sqlcmd
语句位于同一行。将SQL语句放在单独的文件中可能最简单,并使用-i
开关从文件中读取查询。