SQL server中sqlcmd命令行工具的使用方法.doc
文本预览下载声明
SQL server中sqlcmd命令行工具的使用方法
SQL server2008在C:\Program Files\Microsoft SQL Server\100\Tools\Binn,有的可能在
C:\Program Files\Microsoft SQL Server\90\Tools\Binn,你自己找找。
然后看看PATH路径中有没有path=
C:\Program Files\Microsoft SQL Server\100\Tools\Binn
默认你安装了MS server就会有。如果是sql2000的话.那么就用osql连接,如以下例子,osql -S Localhost -U sa -P 123 注意大小写 select count(*) from sysobjects 如果在sql2005及以上版本下,把上面脚本的OSQL改为sqlcmd是可以运行的。
我使用2008使用OSQL会出现,用SQLCMD代替的提示:
使用工具OSQL:
C:\Users\Administratorosql -? //查看osql用法C:\Users\Administratorosql -S ZLQ-PC -U sa -P 123 ?Microsoft (R) SQL Server Command Line ToolVersion 10.0.1600.22 NT INTEL X86Copyright (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]
解释:
参数-????????? 显示?? osql?? 开关的语法摘要。???????? -L???????? 列出在本地配置的服务器和在网络上广播的服务器的名称。???????? -U?? login_id???????? 用户登录?? ID。登录?? ID?? 区分大小写。???????? -P?? password???????? 是用户指定的密码。如果未使用?? -P?? 选项,osql?? 将提示输入密码。如果在命令提示符的末尾使用?? -P?? 选项而不带密码,osql?? 使用默认密码?? (NULL)。密码区分大小写。??????? OSQLPASSWORD?? 环境变量使您
显示全部