我创建了一个批处理文件,它使用bcp从一系列SSMS查询中输出数据。批量使用bcp的多行SQL查询
出于可读性和维护,我想要设定每个查询作为变量跨越多个线,其中我的BCP呼叫中引用,例如:
SET myQuery =
"select a, b, c, d "
"from tableA a "
"inner join tableB b "
"on a.Id = b.ID "
"where a.value < .99 "
"order by a.Id "
bcp %myQuery% queryout C:\myDir\filenameOut.txt -S ServerName -T -c
我已经发现了克拉运营商做了类似的,并应用如此:
SET myQuery =
"select a, b, c, d "^
"from tableA a "^
"inner join tableB b "^
"on a.Id = b.ID "^
"where a.value < .99 "^
"order by a.Id "
无济于事。错误消息说:
“[第一行内容]不被识别为内部或外部 命令,可操作的程序或批处理文件。”
这让我觉得行不是正确连接。
我认识到批处理文件通常不能很好地处理像这样的多行操作,但是有没有一种简单的方法来实现这一点?
您需要将关键字多个空格什么。 –
@GordonLinoff,'关键字'是指SQL查询的内容? – Chris