【经典】sqlcmd 和 osql(Sql Server)

来源:互联网 发布:计数器软件下载 编辑:程序博客网 时间:2024/06/08 12:02

【转】  http://hi.baidu.com/wyd45123/blog/item/33fa574e3bf50dc1d0c86a82.html

新的sqlcmd取代了Sql Server 2000的osql
通过osql来列出本地网内的Sql Server 服务器列表。使用参数有两种显示方式。
C:/Documents and Settings/Administrator>sqlcmd -L
C:/Documents and Settings/Administrator>sqlcmd -Lc
连接本地数据库sqlexpress版本
sqlcmd -S ./sqlexpress

以下是osql和sqlcmd的帮助
C:/Documents and Settings/...>osql/?
Microsoft (R) SQL Server Command Line Tool
Version 10.0.1600.22 NT INTEL X86
Copyright (c) Microsoft Corporation. All rights reserved.

Note: osql does not support all features of SQL Server 2008.
Use sqlcmd instead. See SQL Server Books Online for details.

usage: osql              [-U login id]          [-P password]
[-S server]            [-H hostname]          [-E trusted connection]
[-d use database name] [-l login timeout]     [-t query timeout]
[-h headers]           [-s colseparator]      [-w columnwidth]
[-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]
[-L list servers]      [-c cmdend]            [-D ODBC DSN name]
[-q "cmdline query"]   [-Q "cmdline query" and exit]
[-n remove numbering] [-m errorlevel]
[-r msgs to stderr]    [-V severitylevel]
[-i inputfile]         [-o outputfile]
[-p print statistics] [-b On error batch abort]
[-X[1] disable commands [and exit with warning]]
[-O use Old ISQL behavior disables the following]
      <EOF> batch processing
      Auto console width scaling
      Wide messages
      default errorlevel is -1 vs 1
[-? show syntax summary]

-----------------------------------------------------------
C:/Documents and Settings/wangyd>sqlcmd/?
Microsoft (R) SQL Server Command Line Tool
Version 10.0.1600.22 NT INTEL X86
Copyright (c) Microsoft Corporation. All rights reserved.

usage: Sqlcmd            [-U login id]          [-P password]
[-S server]            [-H hostname]          [-E trusted connection]
[-d use database name] [-l login timeout]     [-t query timeout]
[-h headers]           [-s colseparator]      [-w screen width]
[-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]
[-c cmdend]            [-L[c] list servers[clean output]]
[-q "cmdline query"]   [-Q "cmdline query" and exit]
[-m errorlevel]        [-V severitylevel]     [-W remove trailing spaces]
[-u unicode output]    [-r[0|1] msgs to stderr]
[-i inputfile]         [-o outputfile]        [-z new password]
[-f <codepage> | i:<codepage>[,o:<codepage>]] [-Z new password and exit]
[-k[1|2] remove[replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] print statistics[colon format]]
[-R use client regional setting]
[-b On error batch abort]
[-v var = "value"...] [-A dedicated admin connection]
[-X[1] disable commands, startup script, enviroment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]

更多参考:http://msdn.microsoft.com/zh-cn/library/ms180944.aspx

原创粉丝点击