Search code examples
sql-server-2008-r2sqlcmd

SQLCMD.exe window is not opening


On Windows Server 2012 we have SQL Server 2008-R2 Enterprise installed that does have SQLCMD but when I try to open the utility its black console window opens for a fraction of a second and then disappears. What may be the cause and how can we open the window and/or resolve the issue?


Solution

  • Sqlcmd is really intended to be run like a terminal program from a shell such as command prompt (cmd.exe) or PowerShell. If you're just running sqlcmd.exe from the Run window or the start menu, the default behavior is to open a trusted connection to the local system. It's equivalent to running:

    sqlcmd.exe -S 127.0.0.1 -E
    

    If the window just displays a black screen, it's because it's trying to connect and isn't succeeding. If you hit Ctrl+C, you should get the message "Canceling connection. Please wait...Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Operation was canceled.." or similar.

    If you're unable to connect, perhaps you're not specifying the correct parameters to connect to the instance, or the instance is stopped, or the instance isn't configured correctly.

    Try connecting with SQL Server Management Studio or another SQL client. Check SQL Server Configuration Manager to be sure that your instance is started and that it's listening appropriately.