首页 > 代码库 > 命令提示符中运行SQL Server 2005

命令提示符中运行SQL Server 2005

 

 
使用 sqlcmd 实用工具,可以在命令提示符处、SQLCMD 模式下的查询编辑器、Windows 脚本文件或 SQL Server 代理作业的操作系统 (Cmd.exe) 作业步骤中,输入 Transact-SQL 语句、系统过程和脚本文件。 此实用工具使用 OLE DB 执行 Transact-SQL 批处理。

sqlcmd
[{ { -U login_id [ -P password ] } | –E trusted connection }]
[ -z new password ] [ -Z new password and exit]
[ -S server_name [ \ instance_name ] ] [ -H wksta_name ] [ -d db_name ]
[ -l login time_out ] [ -A dedicated admin connection ]
[ -i input_file ] [ -o output_file ]
[ -f < codepage > | i: < codepage > [ < , o: < codepage > ] ]
[ -u unicode output ] [ -r [ 0 | 1 ] msgs to stderr ]
[ -R use client regional settings ]
[ -q "cmdline query" ] [ -Q "cmdline query" and exit ]
[ -e echo input ] [ -t query time_out ]
[ -I enable Quoted Identifiers ]
[ -v var = "value"...] [ -x disable variable substitution ]
[ -h headers ][ -s col_separator ] [ -w column_width ]
[ -W remove trailing spaces ]
[ -k [ 1 | 2 ] remove[replace] control characters ]
[ -y display_width ] [-Y display_width ]
[ -b on error batch abort ] [ -V severitylevel ] [ -m error_level ]
[ -a packet_size ][ -c cmd_end ]
[ -L [ c ] list servers[clean output] ]
[ -p [ 1 ] print statistics[colon format] ]
[ -X [ 1 ] ] disable commands, startup script, enviroment variables [and exit]
[ -? show syntax summary ]

简例:
sqlcmd -U sa -P 1234567 -S 192.168.1.1
注意大小写、

命令提示符中运行SQL Server 2005