| title | Start the sqlcmd Utility | Microsoft Docs | |
|---|---|---|
| ms.custom | ||
| ms.date | 03/06/2017 | |
| ms.prod | sql-server-2014 | |
| ms.reviewer | ||
| ms.suite | ||
| ms.technology |
|
|
| ms.tgt_pltfrm | ||
| ms.topic | article | |
| ms.assetid | 00d57437-7a29-4da1-b639-ee990db055fb | |
| caps.latest.revision | 39 | |
| author | JennieHubbard | |
| ms.author | jhubbard | |
| manager | jhubbard |
To begin using sqlcmd, you must first launch the utility and connect to an instance of [!INCLUDEssNoVersion]. You can connect to either a default or named instance. The first step is to start the sqlcmd utility.
Note
Windows Authentication is the default authentication mode for sqlcmd. To use [!INCLUDEssNoVersion] Authentication, you must specify a user name and password by using the -U and -P options.
Note
By default, [!INCLUDEssExpress] installs as the named instance sqlexpress.
If you have not connected to this instance of the [!INCLUDEssDEnoversion] before, you may have to configure [!INCLUDEssNoVersion] to accept connections.
-
On the Start menu click Run. In the Open box type cmd, and then click OK to open a Command Prompt window.
-
At the command prompt, type
sqlcmd. -
Press ENTER.
You now have a trusted connection to the default instance of [!INCLUDEssNoVersion] that is running on your computer.
1> is the
sqlcmdprompt that specifies the line number. Each time you press ENTER, the number increases by one. -
To end the
sqlcmdsession, typeEXITat thesqlcmdprompt.
-
Open a Command Prompt window, and type
sqlcmd -SmyServer\instanceName. Replace myServer\instanceName with the name of the computer and the instance of [!INCLUDEssNoVersion] that you want to connect to. -
Press ENTER.
The
sqlcmdprompt (1>) indicates that you are connected to the specified instance of [!INCLUDEssNoVersion].[!NOTE]
Entered [!INCLUDEtsql] statements are stored in a buffer. They are executed as a batch when the GO command is encountered.