error "Could not open a connection to SQL Server"

  • Hello!

    I'd like to run mssql script (file with extension sql). I installed Microsoft SQL Server 2008 and run in Command Prompt:

    C:\Documents and Settings\useruser>osql -Usa -Ppassword -i "F:\Data\MyApplication\Scripts\CreateDb.sql"

    [SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2].

    [SQL Server Native Client 10.0]Login timeout expired

    [SQL Server Native Client 10.0]A network-related or instance-specific error has occured while establishing a connection to SQL Server. Server is not found of not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

    I found that I should choose:

    area configuration manager -> allow remote connection

    Somewhere else I found that it is here:

    Configuration Tools->SQL Server Configuration Manager; Configuration Tools->SQL Server Surface Area Configuration; SQL Server Management Studio Express ...

    But I don't have anything like this. When I enter "Sql Server Configuration Manager" there are:

    SQL Server Configuration Manager (Local)

    SQL Server Services

    SQL Server Network Configuration

    Protocols for SQLEXPRESS

    SQL Native Client 10.0 Configuration

    Client Protocols

    Aliases

    What should I do to get rid of these errors? How to run this script?

    Greetings!

  • If you run osql without the -S parameter, it will try to connect to the default instance.

    If yours is a named instance (i.e. machinename\instancename), you will need to specify this using the -S parameter.

  • I run it without -S:

    osql -Ua -Ppassword -i "F:\Data\Name_of_directory\Scripts\CreateDb.sql

    and there are the same errors. (It doesn't ask me about any password).

    Greetings!

  • By default the express edition of SQL Server, you have a named instance. I believe it's SQLEXPRESS, which means the name is [machine name]\SQLEXPRESS and you will need to use the -S parameter.

  • johnyjj,

    Here's a link to get SSMS express installed:

    http://msdn.microsoft.com/en-us/library/ms365247.aspx

    I'm not sure with the Express edition, but with full installs, if you don't choose to install the "tools, documentation" option, SSMS doesn't get installed. You can, of course, add it later.

    As the others stated, you can probably get your script running from the command line, but if you'd like the GUI, follow that link.

    HTH

    ----------------------------------------------------------------------------
    Sacramento SQL Server users group - http://sac.sqlpass.org
    Follow me on Twitter - @SQLDCH
    ----------------------------------------------------------------------------

    Yeah, well...The Dude abides.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply