What are the differences between osql, isql, and sqlcmd?

前端 未结 4 1399
挽巷
挽巷 2021-02-01 03: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. Howe

相关标签:
4条回答
  • 2021-02-01 03:22

    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.

    0 讨论(0)
  • 2021-02-01 03:28

    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.

    0 讨论(0)
  • 2021-02-01 03:32

    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

    0 讨论(0)
  • 2021-02-01 03:41

    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)
    0 讨论(0)
提交回复
热议问题