【经典】sqlcmd 和 osql(Sql Server)

【转】  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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值