TDsveR=8.0 tsql -H servername -p 1433 -D dbadmin -U domain\administrator -P password
然后我有我的SQL查询:
USE dbname GO delete from schema.tableA where ID > 5 GO delete from schema.tableB where ID > 5 GO delete from schema.tableC where ID > 5 GO exit
这通过freeTSD命令行手动执行时有效,但是当我放入bash文件时则不行.我关注这篇文章:freeTSD & bash.
这是我的bash脚本示例:
echo "USE dbname GO delete from schema.tableA where userID > 5 go delete from schema.tableB where userID > 5 go delete from schema.tableC where ID > 5 GO exit" > tempfile | TDsveR=8.0 tsql -H servername -p 1433 -D dbname -U domain\administrator -P password < tempfile
bash脚本的输出是:
locale is "en_US.UTF-8"locale charset is "UTF-8"Default database being set to sbdb1> 2> 3> 4> 5> 6> 7> 8>
然后我的脚本的其余部分被执行.
有人能给我一步一步解答我的问题吗?
解决方法 我不确定你的样品是如何起作用的.这是我的bash脚本示例:
echo "USE dbname .... exit" > tempfile | TDsveR=8.0 tsql -H servername -p 1433 -D dbname -U domain\administrator -P password < tempfile# ------------------------------------^^^^ ---- pipe char?
尝试使用’;’焦炭.
echo "USE dbname .... exit" > tempfile ; TDsveR=8.0 tsql -H servername -p 1433 -D dbname -U domain\administrator -P password < tempfile# ------------------------------------^^^^ ---- semi-colon
更好的是,使用shell的“here documents”.
TDsveR=8.0 tsql -H servername -p 1433 -D dbname -U domain\administrator -P password <<EOS USE dbname GO delete from schema.tableA where userID > 5 go delete from schema.tableB where userID > 5 go delete from schema.tableC where ID > 5 GO exit EOS
IHTH.
当前命令行输入:
echo "delete from table where userID > 5godelete from table where userID > 5godelete from table where ID > 5GOexit" < /tmp/tempfile; TDSDUMP=/tmp/freetds.log TDsveR=8.0 tsql -H servername -p 1433 -D dbname -U administrator -P password <<EOS总结
以上是内存溢出为你收集整理的linux – freeTDS bash:在Microsoft SQL Server中执行sql查询全部内容,希望文章能够帮你解决linux – freeTDS bash:在Microsoft SQL Server中执行sql查询所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)