I had installed SQL Server 2008 R2 "SQL Server Database Engine" in virtual machine and I want to connect to it over odbc from other computer (Linux).

I hadn't installed management studio as I wanted minimal possible installation (it is mostly for very basic testing purposes not for real work).

I hadn't installed Management Studio and I don't want to install it.

During installation procedure I provided a user and password for connection however, looks like thing went wrong and I can't login using this user.


  1. I have installed "Database Engine" and configured TCP connection
  2. I can connect to it using isql but it reports that user does not exist.
  3. I see in Event Log (of Windows) complains that user does not exist.
  4. I've tried to run import tool and managed to login using XP user on same PC and could run simple queries, however this tool does not allow me to run a statement so I can't run CREATE LOGIN user-name WITH PASSWORD='secret'.

How can I connect to this database and add new users?

Basically at this point I have two options:

  1. Reinstall database, but:

    I don't want to and nothing promises that this time it would work and create a user.

  2. Install management studio I don't want it is huge install for virtual machine.


Is there any simple command line tool to access DB in place just to run several statements using XP authentication without a huge Management studio tool?

Solution Summary:

  1. Use sqlcmd -Q "create login ..." to run sql statements I need. sqlcmd.exe is installed with "SQL Server Database Engine"
  2. My user wasn't defined correctly during the installation because MS SQL didn't like my password I had given and it didn't alert me on the problem...
  • 3
    It seems silly to not use the purpose built tools that come packaged with the product just to save a few hundred MB.
    – DanBig
    Nov 18, 2010 at 14:40
  • 1
    @Dan not in case when you have 1-2GB of virtual disk in virtual machine. Especially when you don't need them.
    – Artyom
    Nov 18, 2010 at 15:06
  • 4
    @Artyom: As someone who manages numerous SQL Server instances from Sql 2000 - 2008, creating a VM to throw XP (at least) just to run SSMS makes sense. SSMS is your friend..not the enemy you're making it out to be..
    – GregD
    Nov 18, 2010 at 15:17
  • 1
    @GregD I believe it is not enemy, in fact I know this tool and work with it in other environments. However the fact is I want smallest possible MS SQL Server installation on small VM to run basic tests. So I want to keep things small. I don't need any fancy stuff. I don't need to manage many servers I need simple client to execute a simple command. Does it make sense to install huge application to run few SQL commands? At least in the world I come from (Linux) it doesn't. So I home sqlcmd solves the problem for me and I'll accept the answer as soon as I get to the computer.
    – Artyom
    Nov 18, 2010 at 15:26
  • 1
    @GregD - you see, finally given a simple tool sqlcmd I just didn't know to find because I looked on E: instead of C: did the job perfectly well. That is entire point. Do things simple. Downloading 150MB of software and installing it into more space to run just a simple command is wrong!
    – Artyom
    Nov 18, 2010 at 20:32

2 Answers 2


sqlcmd will allow you to run commands against the server using Windows or SQL Authentication. If something's gone wrong and you've ended up with no windows accounts granted rights to the server then you can start SQL Serve in single user mode to get access and create new accounts.

  • is sqlcmd included in "SQL Server Database Engine" or it is part of management studio? Because I searched for all exes in installation and hadn't found this one (or I missed it)
    – Artyom
    Nov 18, 2010 at 13:54
  • 2
    @Artyom - for me, sqlcmd is {program files}\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE Nov 18, 2010 at 15:10
  • Thanks. I'll give it a try as soon as I get to this computer.
    – Artyom
    Nov 18, 2010 at 15:27
  • Thanks you very much, it was on "C:\" even I installed MS SQL on "E:" ... This really helped me.
    – Artyom
    Nov 18, 2010 at 20:29
  • I had to go in to single user mode myself. Adding ;-m to the end of the service startup parameters and restarting did it. Make sure to return it to normal once you have your account added.
    – Chris
    Nov 6, 2012 at 21:33

On my system, which is SQL 2008 (not R2), sqlcmd.exe is located in "C:\Program Files\Microsoft SQL Server\100\Tools\Binn". If you are using R2, it might be a slightly different path. You could try looking for "osql.exe". osql.exe works mostly the same as sqlcmd but predates sqlcmd.exe and is not quite as full-featured. On my system, osql.exe is in the same Binn directory as sqlcmd.exe.

Even when I intend to administer the server remotely, I find that installing the tools on the server, along with the SQL services, causes much less pain than not installing them. And I've been using SQL Server for 12 years. Certain things (like replication) are very difficult to do by manually writing Transact-sql because the stored procedure calls can be very complex, and often some seemingly trivial utility that you wind up needing is missing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .