Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2007
    Posts
    11

    Unanswered: SQLCMD Can not connect to SQLExpress 2005

    I have installed SQL Express 2005 on a machine and I am trying to run a script file via SQLCMD from my application. I keep getting an error stating that SQLCMD can not connect to the server. Remote connections are enabled for both tcp/ip and named pipes. Sql Browser Service is enabled and running.

    I am calling the script like so
    Code:
    sqlcmd -E -S TESTPLATFORM\SQLEXPRESS -i "C:\Program Files\ADMS_Trial\CREATE_DATABASE.sql" -o C:\Error.txt
    This is the error message
    HResult 0x2, Level 16, State 1
    Named Pipes Provider: Could not open a connection to SQL Server [2].
    Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..
    Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

    I can open Management studio and run the script and it works perfectly so I don't really know what is going on. Thanks for any help.

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    when you connect with SSMS, is it from a remote machine?

    what OS is running on the express box? if it's XP SP2, make sure there's an exception in the windows firewall. see: http://support.microsoft.com/default...b;en-us;839269

    finally, here are a couple blog posts to troubleshoot connectivity issues in sql server:
    http://blogs.msdn.com/sql_protocols/...22/483684.aspx
    http://blogs.msdn.com/sql_protocols/...29/486861.aspx
    Last edited by jezemine; 02-27-07 at 00:28.

  3. #3
    Join Date
    Jan 2007
    Posts
    11
    No, I am connecting from the machine that it is installed on, and yes it is XP SP2, but I don't see why a firewall would prevent a connection on the local machine. I will check out those links and do some testing when I get back to the office on Friday, thanks.

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    i didn't realize you were connecting locally.

    what happens if you try this:

    -S .\SQLEXPRESS

    instead of

    -S TESTPLATFORM\SQLEXPRESS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •