Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 204
Ray Avatar asked Dec 03 '08 18:12

Ray


People also ask

What is difference between ISQL and OSQL?

Command line utility osql has a main function of providing an interface for the ODBC based query to the SQL server. Osql also allows users to submit a job performed. Isql is a utility whose main function is to allow for Transact-SQL statements.

What is Osql command?

OSQL is a command line tool that allows you to issue commands to Microsoft SQL Server. To run OSQL, simply bring up a DOS box and type OSQL followed by any required switches.

What is Osql utility in SQL Server?

The osql utility allows you to enter Transact-SQL statements, system procedures, and script files. This utility uses ODBC to communicate with the server. Important. This feature will be removed in a future version of SQL Server.

What is the purpose of using SQLCMD?

Running Transact-SQL script files using sqlcmd You can use sqlcmd to execute database script files. Script files are text files that contain a mix of Transact-SQL statements, sqlcmd commands, and scripting variables. For more information about how to script variables, see Use sqlcmd with Scripting Variables.


Video Answer


1 Answers

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.

like image 198
Dave Markle Avatar answered Sep 30 '22 22:09

Dave Markle