Running Microsoft SQL Server From A VS2012 Command Prompt

Having a connection to Microsoft SQL Server in the command prompt provides you with an easily disposable window that you can use to query a database without resorting to the SQL Server Management Studio. Personally, I like to have it tucked into a little corner of my screen where It can be easily accessed; for tasks such as checking if i have a connection to the server,  listing tables in a database and running simple queries. Lets see how we can get a connection to SQL Server up and running in a VS2012 DOS Box.


  1. Open a visual studio command prompt dos box.
  2. Type CD/ at the command prompt.
  3. At the command line enter sqlcmd -S [SERVERNAME|IP] -U [USERNAME] -P [PASSWORD]

*NB: The parameters in [] should be replaced with the actual authentication details of the server that you want to connect to. Each command should be followed by the GO directive in order for them to be executed.

Here is an example of a connection to a server running on my machine using sqlcmd -S .

That’s how its done, see you next time.