SQL SERVER的命令行工具Osql的用法
C:\>osql /?
用法: 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]
[-O use Old ISQL behavior disables the following]
<EOF> 正在进行批处理
控制台宽度自动调整
宽消息
默认错误级别为 — 1 对 1
[-? show syntax summary]
Windows集成身份登陆>>>
C:\>osql -E
1>
登陆后执行系统存储过程
1> sp_password NULL,"newpass","sa"
2> go
密码已更改。
1> exit
再来看看sa混合模式登陆>>>
C:\>osql -SLocalhost -Usa -Pnewpass
1>
出现1>提示符表示登陆成功!
再来看看osql命令行下查询C:\>osql -SLocalhost -Usa -Pnewpass
1> use qz
2> Select count(*) from crjsj where kh=0
3> go
-----------
0
(1 行受到影响)
1>
查询系统表
1> select name from sysobjects where xtype='U'
2> go
name
-------------------------------------------------------------------------------
-------------------------------------------------
sjd
sjdz
xgjsz
xtcs
pb
xtsz
qjcc
rszl
rz
t_Open_Event
t_Open_Event_history
xgsj
t_OpenDoorRecord_history
mjjcs2
t_OpenDoorRecord
mjjz2
mjkzqcs2
dtproperties
qjcc1
sjlxsm
kqsj2
bell
bm
card
department
crjsj
gly
gzsj_history
crjsj_history
jr
gzsj
kqjsz
gzsj_ssjksj
info
lever
kqbc
kqsj
kqsj_tp
lscrjsj
mjjcs
msgrz
parameter
picture
mjjz
qjlb
mjkzqcs
(46 行受到影响)
1>Exit
C:\>Osql 命令行的用途还很多,功能十分强大,常用就列举这些了。