如何在命令提示符 (CMD) 中执行 SQL 语句
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20965846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to execute SQL statements in command prompt (CMD)
提问by Dhanish Jose
how to execute SQL statements in command prompt (CMD),
如何在命令提示符 (CMD) 中执行 SQL 语句,
I'm using SQL Server 2012 in windows 8 OS.
我在 Windows 8 操作系统中使用 SQL Server 2012。
I have tried sqlplus and sqlcmd, both are giving error "
我试过 sqlplus 和 sqlcmd,两者都给出错误“
Thanks in advance.
提前致谢。
回答by Lingasamy Sakthivel
You are looking for the sqlcmd
utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt
您正在寻找的sqlcmd
实用程序可让您在命令提示符下输入 Transact-SQL 语句、系统过程和脚本文件
sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName
-Q "query"
Refer this
参考这个
Edit: The OP said The sqlcmd.exe
file is available in the installation path C:\Program Files\Microsoft SQL Server\110\Tools\Binn
编辑:OP说该sqlcmd.exe
文件在安装路径中可用C:\Program Files\Microsoft SQL Server\110\Tools\Binn
You are executing with C:\Users>
make the path to C:\Program Files\Microsoft SQL Server\110\Tools\Binn
and execute sqlcmd
or add the sqlcmd
path (C:\Program Files\Microsoft SQL Server\110\Tools\Binn)
to system PATH
您正在执行C:\Users>
make path toC:\Program Files\Microsoft SQL Server\110\Tools\Binn
并执行sqlcmd
或将sqlcmd
路径添加(C:\Program Files\Microsoft SQL Server\110\Tools\Binn)
到系统PATH