[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[网络工具] 两个SQLCMD 用于连接SQLserver和执行SQL

AnalogX SQLCMD

http://www.analogx.com/contents/ ... d/Documentation.htm
  1. nalogX SQLCMD allows you to quickly and easily run SQL queries against ODBC data sources. Basically, it's a simple portable way to execute SQL commands from batch files, etc.
  2. SQLCMD is like most command line utilities out there; from the command prompt you can type the name by itself to get a list of options:
  3. F:\tools\sqlcmd> sqlcmd
  4. AnalogX SQLCMD version 1.00 (Release)
  5. The latest version can always be found at http://www.analogx.com/
  6. Usage:   SQLCMD [options]
  7. Options: /USER [name]          Username to login as
  8.          /PASS [password]      Password for username
  9.          /DB [database]        Name of ODBC connection to use
  10.          /LOG [filename]       Log results to file
  11.          /APPEND               Append results to file
  12.          /SILENT               Do not decode results
  13.          /COMMAND [cmd]        SQL command to execute
  14. Here's a brief description of each option:
  15.     USER        This is the username to login to the database with.  This field
  16.                 is optional and will try to log in using a NULL account when it
  17.                 is not supplied.
  18.     PASS        Password for username specified above.
  19.     DB          ODBC Database to connect to.
  20.     LOG         Specify the filename to log to.  Useful for debugging or keeping
  21.                 track of operations performed.  While not a log in the normal
  22.                 sense, it outputs all information pertaining to commands run.
  23.     APPEND      Instead of overwriting the existing log file, it will append
  24.                 onto it.
  25.     SILENT      Suppresses all text output.
  26.     COMMAND     SQL query to perform
  27. It's all pretty straight-forward (to my thinking, at least). Here's a couple of examples:
  28.     sqlcmd /log "C:\Logs\sqlcmd.log" /append /db "Website" /command "select * from [users]"
  29. or:
  30.     sqlcmd /user Jimmy /pass Password /db "Website" /command "update [users] set Downloads=1"
  31. also, if you execute it like so:
  32.     sqlcmd /user Han /db "Website"
  33. without the /COMMAND then it will go into it's "interactive" mode, where you can just enter in SQL queries. Once in this mode, simply type 'QUIT' and it will exit.
  34. If the program thinks it has successfully executed the command, it will return 0, otherwise it will return 1 (these are normally the defaults for success and failure for command line programs), so it should be easy to include SQL commands into batch files.
复制代码

另一个是SQL SERVER中自带的SQLCMD
https://msdn.microsoft.com/en-us/library/ms162773(v=sql.130).aspx

还有OSQL
https://msdn.microsoft.com/en-us/library/ms162806.aspx

TOP

返回列表