What are the differences between osql, isql, and s

2020-05-18 06:01发布

I am interested in using some kind of a command-line utility for SQL Server similar to Oracle's SQL*Plus. SQL Server seems to have several options: osql, isql, and sqlcmd. However, I am not quite certain which one to use.

Do they all essentially do the same thing? Are there any situations where it is preferable to use one over the others?

4条回答
趁早两清
2楼-- · 2020-05-18 06:25

There is a free tool "SQLSPlus" (on http://www.memfix.com ) which is exactly like Oracle SQLPlus for SQL Server. Works with all SQL Server versions.

Very flexible with data formatting (set lines size, pagesize, etc), variables (var, &, &&), spool, HTML output, etc - lots of added functionality comparing to isql, osql or sqlcmd

查看更多
家丑人穷心不美
3楼-- · 2020-05-18 06:48

Its always better to use SQLCMD instead of OSQL or ISQL if you have SQL SERVER 2005, otherwise use OSQL instead of ISQL.

Microsoft has announced before that ISQL was on its way out. Sure enough, ISQL is not included in SQL Server 2005 RTM. OSQL eventually will be phased out also, although it is still included in SQL Server 2005 binary install. With the historical SQL Server release cycle in mind, maybe OSQL will bid us adieu in 2010.

SQLCMD has many advantages as below:

  • 1) Performance wise
  • 2) SQLCMD supports parameterized variables
  • 3) SQLCMD support Customized editor
  • 4) :XML [ONOFF]
  • 5) :Error STDERRSTDOUT
  • 6) :Perftrace STDERRSTDOUT
  • 7) Remote Dedicated Admin Connection (DAC)
查看更多
闹够了就滚
4楼-- · 2020-05-18 06:51

I'm not sure what the scope of your question is, but I believe :

isql used DB-Library to communicate to the server and is no longer included after SQL2000

osql used ODBC to communicate to the server and will no longer included after SQL2005

sqlcmd used OLE DB to communicate to the server and is currently the recommended command line tool.

查看更多
Rolldiameter
5楼-- · 2020-05-18 06:52

Use sqlcmd-- it's the most fully featured product.

  • sqlcmd: The newest, fanciest command-line interface to SQL Server.
  • isql : The older, DB-Library (native SQL Server protocol) way of command-line communication with SQL Server.
  • osql : The older, ODBC-based way of command-line communication with SQL Server.

EDIT: Times have changed since I replied on this a couple of years ago. Nowadays, you can also use the invoke-sqlcmd cmdlet in PowerShell. If you're used to PowerShell or plan to do any scripting of any sophistication, use this instead.

查看更多
登录 后发表回答