SQLCMD Utilitysql command是微软一个win32控制台命令工具,它可以运行及时查询sql语句和脚本。它代替了sql server2000和以前的osql,isql等命令,可以参考这里的帮助http://www.588188.com/netbook/sqlserver2000/coprompt/cp_osql_1wxl.htm,http://www.588188.com/netbook/sqlserver2000/coprompt/cp_isql_8r39.htm。大家如果用过oracle中的sql*plus的话,就会明白这个工具的用途了。它的图形化工具在以前版本就是查询分析器了,现在在Yukon中用强大的带有开发调试集成的sql server管理中心,叫sql server manager studio.看微软的产品,都是用studio命名,这决定了他在软件领域的功能,业务,技术,开发的强大集成。Yukon中还有一个用于BI的business intelligence develop studio,以前有visual stuio 6.0,现有visual studio 2005,好了,转入主题。首先这是个console命令进入cosole的command Prompt,使用sqlcmd +参数等命令,可以连接上server 实例,数据库,运行sql和运行script file,将运行结果到处等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[and exit with warning]] [-? show syntax summary]Z:\>sqlcmd -s grd-peter-wang1> use northwind2> goChanged database context to 'Northwind'.1> select top 1 orderid from orders2> goorderid----------- 10248
(1 rows affected)运行外部script file的语法:sqlcmd -S myServer -i C:\myScript.sql
转载于:https://www.cnblogs.com/PeterWang/archive/2004/10/18/53621.html
相关资源:关于SQLServer2005的学习笔记 XML的处理