On my old machine, I have SQL Server 2008. I have a database placed in a specific folder.
I am now moving to a new machine and I have duplicated the setup with file placements.
On the new machine I have downloaded SQL Server 2019 Express and SQL Server Management Studio 18.
OK. So doing this simply I make sure SQL Server Express is running, open SSMS and in Object Explorer I choose "Mynewmachine\SQLExpress" - "Databases" and I click "Attach" pick my database (MDF file on local disk)
However doing this I get error:
Attached Database failed for server Mynewmachine\SQLExpress
(Microsoft.SqlServer.Smo) Additional information: An exception
occurred while executing a transact-sql statement or batch
(Microsoft.SqlServer.ConnectionInfo) A network-related or
instance-specific error occurred while establishing connection to SQL
Server. The server was not found or was not accessible. Verify that
the instance name is correct and that SQL Server is configured to
allow remote connections. (Provider: SQL Network Interfaces, error: 26
Error location Server/Instance Specified) /Microsoft SQL Server)
This makes little sense. Server is running on local machine. Database files are on local machine (in fact specific database + SQL Server have always been only used locally on old/new machine). Thus there is nothing here with remote connections or anything like that.
I am wondering if this this in an instance name issues. On my new server it is called SQLEXPRESS, and on my old it was MSSQLServer. Should I install a new instance if MSSQLSERVER using the same instance name as on my old machine? Would I then be able to import more easily?
I am trying to create a connection manager in Microsoft SQL Server Data Tools for Visual Studio 2017 (SSDT) for an integration services project.
In the Connection Manager:
The Provider is set to: Native OLE DB\SQL Server Naive Client 11.0
The Server name is set to: the name of the local machine
Log on to the server is set to: Windows Authentication
Connect to a database is set to: Select or enter a database name. However no database names appear in the drop down box - the drop down box is blank. I am expecting the name of the database i am working on, including the master database etc to be present.
When I Test Connection, I get an error message which says:
'Test connection failed because of an error in initializing provider. Login timeout expired
A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or 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.
Named Pipes Provider: Could not open a connection to SQL Server [2]..'
I am using SQL Server 2017 and Microsoft SQL Server Management Studio 18.
Allow remote connections has been ticked in SSMS.
The only thing i can see is the SQL Server Agent and SQL Server Browser has stopped / is not running and the TCP/IP Protocols for SQLEXPRESS is set to disabled - I am unable to enable it without a further Access is denied (0x80070005) error.
I have tried to follow all of the guides but cannot progress. Could somebody please offer some further guidance?
I have resolved the issue. It was an extremely silly oversight! On installation, the server name in the Visual Studio 17 Connection Manager was listed as: Local MachineName only. In SQL Server, the Server Name was listed as: LocalMachineName\SQLEXPRESS. The Server Name in VS17 has to be exactly the same as SQL Server. As i said, this is a very silly oversight on my part but have documented for future reference.
SQL Server Configuration Manager ==> SQL Server Services(Left sidebar) ==> Right Click and Start all Stopped services
I installed SQL Server 2008 (not express) on my PC, but when tried to connect with SSMS, got this message:
A network-related or instance specific error occured while established
a connection to SQL Server. The server was not found or was not
accessible. Verify that the instance name is correct and that SQL
Server is configured to allow remote connections.(provider: Named
Pipes Provider, error: 40- Could not open a connection to SQL Server)
(Misrosoft SQL Server, Error 2)
My connection dialog box to SSMS is:
Server type: Database Engine.
Server name: (local)
Authentication: Windows
What should I check? Where to start troubleshooting?
GO TO >> Run Command (Ctrl + r )
Type -- services.msc
go to SQL SERVER >> Right Click >> Click Start
Again Restart SQL SERVER Studio
Here are some troubleshooting tips that you can do:
Try to run your SSMS as admin
Make sure that you are using the correct server name and instance
Check if your sql server service is running by going to run -> services.msc -> Check SQL Server(Instance Name) service if it is running
Error 40 has many reasons, some of them are related to network configurations which are out of scope in your question. Other reasons which may cause this error and has possibility in your question are as follow:
Make sure that SQL SERVER(XXX) service is running by visiting sql server configuration manager section
Make sure that SQL Browser service is running by visiting sql server configuration manager section
Make sure you are using the correct instance name
Read more about this error
If your server is Local. Try to login with server name . or (local).
If you are still not able to login, check Check SQL Server Configuration Manager (Start>All Programs>MS SQL Server>Configuration Tools>Configuration Manager)
I just installed SQL Server 2008 Express on my Vista SP1 machine. I previously had 2005 on here and used it just fine with the old SQL Server Management Studio Express. I was able to connect with no problems to my PC-NAME\SQLEXPRESS instance (no, PC-NAME is not my computer name ;-).
I uninstalled 2005 and SQL Server Management Studio Express. I then installed SQL Server 2008 Express on my machine and elected to have it install SQL Server Management Studio Basic.
Now, when I try to connect to PC-NAME\SQLEXPRESS (with Windows Authentication, like I always did), I get the following message:
Cannot connect to PC-NAME\SQLEXPRESS.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
When I installed SQL Server 2008, I had it use SQLEXPRESS as the local instance name. As far as I can tell, through SQL Server Configuration Manager, SQL Server is configured to allow remote connections.
When I went to the help link it mentions, the help page suggests the following:
Make sure that the SQL Server Browser service is started on the server.
Use the SQL Server Surface Area Configuration tool to enable SQL Server to accept remote connections. For more information about the SQL Server Surface Area Configuration Tool, see Surface Area Configuration for Services and Connections.
Well, as far as I can tell, there is no SQL Server Browser service on my system (looked in MMC for one, couldn't find one).
And the SQL Server Surface Area Configuration tool doesn't exist in SQL Server 2008. So good job there with your help documentation, Microsoft ;-).
I'm at a loss for what to do right now. I had a lot of work I was hoping to get done today after upgrading to 2008 (the person I'm working with got it up and running with no problem and told me it would be easy - he's also far better with database stuff that I am). Does anyone have any idea what might be wrong? I'd really appreciate it. If I can't get this working in a few hours, I'm going back to SQL Server 2005 (if that will even work, gah...).
Edit: I have tried turning Windows Firewall off, and that did not help. Also, I noticed that I do not have a "Data" directory under my SQL Server 2008 install directory tree - could I have possibly set something up wrong when I installed it?
Please check the ServerName which you provided. It should match with the below shown Name in the UserName textbox, and that name should followed with \SQLEXPRESS:
Start your Local SQL Server Service
Start SQL Config Manager: Click Start -> Microsoft SQL Server 2008 R2 -> SQL Server
Configuration Manager
Start SQL Services: Set the SQL Server (SQLEXPRESS) and SQL Server Browser services to automatic
start mode. Right-click each service -> Properties -> Go into the Service Tab
This will ensure they start up again if you restart your computer. Please check to ensure the state is "Running" for both services.
Login and authenticate with your Local SQL Server
Now open up SQL Server Management Studio and click "Connect to Object
Explorer" and select Server Name:
[Your PC name]\SQLEXPRESS
Example: 8540P-KL\SQLEXPRESS or (localhost)\SQLEXPRESS
To find your PC name: Right click My Computer -> Properties ->
Computer Name tab
Alternative: Login using windows authentication: Using the user name [Your
Domain]/[Your User Name]
Setup User Account
Create a new Login acct: In SQL Mgmt Studio -> Expand your local Server -> Security -> Right
click on Logins -> New Login
Set Password settings on New User Account: Uncheck Enforce password policy, password expiration and user must
change pw(Since this is local) Default database -> Your Database
Grant roles to New User Account: User Mapping Page -> Map to your db and grant db_owner role Status
Page -> Grant Permission to connect and Enable Login
Setup Access Permissions/Settings for User
Enable all auth modes: Right click your Local Server -> Properties -> Security Tab -> Enable
SQL Server and Windows Authentication Mode
Enable TCP/IP: Open SQL Server Configuration Manager -> SQL Server Network
Configuration -> Protocols for SQLEXPRESS -> Enable TCP/IP
Restart SQL Server Service: You will have to restart the SQL Server(SQLEXPRESS) after enabling TCP/IP
Database Properties File for Spring Project
database.url=jdbc:jtds:sqlserver://[local PC Computer
name];instance=SQLEXPRESS;DatabaseName=[db name];
database.username=[Your user name] database.password=[Your password]
database.driverClassName=net.sourceforge.jtds.jdbc.Driver
If you want to view larger screen shots and better formatting of the answer with more details please view the blog article below:
Setting up a Local Instance of SQL Server 2008 Blog Post:
I used (LocalDB)\MSSQLLocalDB as the server name, I was then able to see all the local databases.
Haha, oh boy, I figured it out. Somehow, someway, I did not install the Database Engine when I installed SQL Server 2008. I have no idea how I missed that, but that's what happened.
I know this question is old, but in case it helps anyone make sure the SQL Server Browser is running in the Services MSC. I installed SQL Server Express 2008 R2 and the SQL Server Browser Service was set to Disabled.
Start->Run->Services.msc
Find "SQL Server Browser"->Right Click->Properties
Set Startup Type to Automatic->Click Apply
Retry your connection.
I've just solved a problem related to this which may help other people.
Initially when loading up MSSMSE it had the server as PC_NAME\SQLEXPRESS and when I tried to connect it gave me Error: 26 - Error Locating Server/Instance Specified, so I went into SQL Server Configuration Manager to check if my SQL Server Browser and SQL Server services were running and set to automatic, only to find that instead of saying SQL Server (SQLEXPRESS) it says SQL Server(MSSQLSERVER).
I then tried connecting to PC-NAME\MSSQLSERVER and this time got SQL Network Interfaces, error: 25 - Connection string is not valid) (MicrosoftSQL Server, Error: 87) The parameter is incorrect so I googled this error and found that somebody had suggested that instead of using PC-NAME\MSSQLSERVER just use PC-NAME as the Server Name at the server connection interface, and this seems to work.
There's a link here http://learningsqlserver.wordpress.com/2011/01/21/what-version-of-sql-server-do-i-have/ which explains that MSSQLSERVER is the default instance and can be connected to by using just your hostname.
I think this may have arisen because I've had SQL Server 2008 installed at some point in the past.
Under Configuration Manager and Network Configuration and Protocols for your instance is TCP/IP Enabled? That could be the problem.
var.connectionstring = "server=localhost; database=dbname; integrated security=yes"
or
var.connectionstring = "server=localhost; database=dbname; login=yourlogin; pwd=yourpass"
For me, I was only able to get it to work by using "." in the server name field; was banging away for awhile trying different combos of the user name and server name. Note that during install of the server (ie this file: SQLEXPR_x64_ENU.exe) i checked default instance which defaults the name to MSSQLSERVER; the above high voted answers might be best used for separate named (ie when you need more than 1) server instances.
both of these videos helped me out:
use dot for server name: https://www.youtube.com/watch?v=DLrxFXXeLFk
general setup: https://www.youtube.com/watch?v=vng0P8Gfx2g
One of the first things that you should check is that the SQL Server (MSSQLSERVER) is started. You can go to the Services Console (services.msc) and look for SQL Server (MSSQLSERVER) to see that it is started. If not, then start the service.
You could also do this through an elevated command prompt by typing net start mssqlserver.
For me it was a windows firewall issue. Allow incoming connections. Opening port didn't work but allow programs did.
Link
Link2
I installed SQLManagementStudio_x64_ENU from Microsoft site on my Windows 7 Home Premium.
It gave me compatibility warnings but I still installed because Microsoft site specified that I would receive warnings but suggested to click on Run Program, which I did.
It was successfully installed. I checked Services.msc, and I can see two SQL Server services are running. I checked SQL Server Configuration, and I can see services running under automatic mode, and the agent is off.
When I open my management studio and try to connect using "Server name" option, I can't see any server instance in browse option. There are no servers to connect. I am not able to connect to the database engine. I have tried at least 10 times, but still, it's not allowing me to connect.
I get the following error:
A network-related or instance-specific error occurred while establishing a
connectionto SQL Server. The server was not found or was not accessible.
Verify that the instance name is correct and that SQL Server is configured to
allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection
to SQL Server) (.Net SqlClient Data Provider)
Can someone help me with this problem?
In the Connect to server dialog of the SQL Server Management Studio (SSMS), type <your machine name>\SQLServer2008 to connect to SQLServer2008 instance. Otherwise, type <your machine name> alone in the server name text box to connect to the default instance SQLExpress.
Following link discusses how to fix the error Microsoft.SqlServer.Management.Dmf.PolicyStore
SSMS 2008 on Windows 7 throws exception when connecting Object Explorer