How to connect to SQL Server 2008 - sql-server

I have a desktop, and a Laptop. The Desktop has Windows 7 64-bit and the Laptop has Vista Ultimate 32-bit. On both machines I have SQL Server 2008 Standard installed.
On the laptop, I open SQL Management Studio and try to connect to the SQL Server on the desktop. It times out.
With SQL Server Config Manager I Enabled TCP/IP and Named Pipes for the client protocols.
In SQL Management Studio, I right clicked on the Database Engine, went to properties, and allowed remote connections. I also created a sql server login named "testuser" and a password. I then added that user as a login for my database and made them the database owner.
I could not figure out how to allow connection to my db throw the windows firewall, so I turned it off.
What am I missing? I made the same changes on my laptop, and I can connect from the Desktop to the Laptop in Management Studio?
Do you have a checklist?
Thanks.
UPDATE:
I turned off antivirus. Ran NetStat -a and the listener is listening.

If your login attempt takes about 30 seconds to timeout, then it's some kind of network connectivity problem (or SQL isn't listening properly). A permissions problem would come back after a few seconds, so the long wait says it's connection-related.
If you run "NETSTAT -a" on the server, so you see SQL Server listening on port 1433? If not, then maybe the SQL TCP Listener isn't configured properly on the server - there should be events in the Windows Event log to this effect when the SQL Service starts up.
Please edit your question with the results and we can go from there.

Try using Telnet to see if the laptop can see the desktop via port 1433.
Open a command prompt on the laptop and enter:
telnet DesktopNameOrIPAddress 1433
Press Enter, and you should either see a connection failed error, or a blank screen. If you get the blank screen, the connection was established. Press CTRL-] to break out of it, then type "quit" and enter to quit.
If the connection failed, attempt to resolve the general network issue with port 1433 before bothering to use the SQL Server tools.

If you have any other anti-virus software running, it may also have a firewall built in. I know that McAfee does, for instance. Check for that.

You've probably already thought of this, but have you checked that the server is configured to allow Mixed Mode Authentication? I have not had access to 2008, but I seem to remember that at least one of the previous versions was configured to disallow sql logins by default.

I assume you already did what you have to do on the OS level. Or maybe tried to link the server to see if you can actually traverse your network. Let me suggest a quick test. Check if you can actually test connectivity by creating a Universal Data Link. In case you don't know how to do this, create a new text file in your desktop (or anywhere) and change the .txt file extension to .udl; then just open it. See if your other server is "viewable" over the network (Don't forget to change the Provider to OLE DB Provider for SQL Server).

Is the SQL Browser Service running on the server you are trying to access? (By default this is disabled, and you'll need that to access SQL Server remotely)

Related

SQL Server 2012 not able to connect to named instance remotely with ssms

I'm running SQL Server 2012 on a Microsoft Windows Server 2012 R2. I am running a named instance called PP. The server authentication is set to "SQL Server and Windows Authentication mode".
When I am logged into the server via Remote Desktop I can log in to the named instance via SSMS just fine using a using a SQL Server username and password. When I try to log into the named instance remotely using the same username and password I get an error as described in this screenshot (my reputation isn't high enough to paste the screenshot directly in my post, please follow the link):
Here are the things I have checked so far:
I can ping the IP Address of the remote server from my local computer and get successful responses.
I have configured the instance of SQL Server to accept remote connections as described in this article.
In SQL Server Configuration Manager on the remote server under the protocols for my named instance I have enabled "Shared Memory", "Named Pipes" and "TCP/IP".
Under "TCP/IP" properties on the remote server in SQL Server Configuration Manager in the "IP Addresses" tab under the "IP2" section I have set the "TCP Dynamic Ports" value to blank. I have tried setting the "TCP Port" value to 1433 and then to 1434 (the difference between a regular instance and a named instance) and going through the rest of the steps below as shown in the screenshot here (these are the values specified in the article I linked to above)
Windows firewall is not running on the remote server, and from what I can see there is not another firewall running on the remote server either.
The SQL Server Browser service on the remote server has been stopped and restarted.
After I have made all of these changes and verified all of these settings the SQL Server service for the named instance on the remote server has been stopped and restarted.
After all of this I am still getting my original error when I try to connect to the named instance of SQL Server on my remote server from my local computer via SSMS. I've been searching high and low and cannot find any additional troubleshooting steps to diagnose this problem. Will someone please point me in the direction of the next steps I should take to fix this? Thanks in advance.
I logged off and then came back the next day to implement the suggestions in #Andrey Nikolov 's answer and for some reason I am able to connect remotely to the named instance now. The settings that ended up working for the "IP2" section of the "TCP/IP" configuration for the named instance are the "TCP Dynamic Ports" value is set to blank and the "TCP port" is set to 1433. I didn't make any other changes. The rest of the configuration is as I noted in my OP. I have sysadmin access to this server but I'm not the actual administrator so I guess it's possible that the actual administrator might have changed something else between when I logged off and then logged back on but I don't know what that might be. Thanks to #Andrey Nikolov for your input.
EDIT:
This issue came back in full force a few days later for no reason that I could determine. After a long search I found a very informative MS Doc that goes through the whole troubleshooting process for this in depth, hope this helps someone else confronted with this. Here's the link:
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/troubleshoot-connecting-to-the-sql-server-database-engine?view=sql-server-2017
It says it's for SQL Server 2017 but I was able to follow it to fix my SQL Server 2012 issue. For my situation it turns out that because I had 2 separate instances of MS SQL on my server the initial instance was using all of the default settings as described elsewhere and my instance I was trying to connect to was using a completely different port. Using this Doc I was able to find out what port my instance is using and specify that in the "Server name" box of SSMS when I tried to connect. Now it works like a charm.
I think your named instance TCP/IP isn't configured properly. In case you connect locally it does not connect using TCP/IP, but using shared memory. You set your instance to listen on port 1434, but this port is used by SQL Browser service and most likely the SQL Server engine service can't open the port (you can confirm that by finding the error in the logs). To make it work you should set IP2 -> TCP Dynamic Ports to be 0 and clear IP2 -> TCP Port. Configured like this, your named instance will use dynamic ports. If you want to configure it to use specific port, replace 1434 in IP2 -> TCP Port with available port number.

Unable to connect to SQL Server instance remotely

I’m trying to access the SQL Server instance on my VPS from SQL Server Management Studio on my local machine. It’s not working (the error I’m getting is:
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.
I think this is because I need to configure the database engine to allow remote connections (correct me if I’m wrong!). So I’ve found this step-by-step guide to help me do that: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ I’ve got to point 10 in the guide and I am now stuck! I don’t have SQL Server Management Studio installed on my VPS. Anyway, this has left me with two options:
Install SSMS
Find another way to do point 10 onwards in the guide without having SSMS installed
I tried installing SSMS on my VPS using the Web Platform Installer but it keeps failing. I don’t know why it’s failing because it doesn’t seem to give a reason why. Does anyone know how I could allow remote connections a different way?
The version of SQL Server installed on my VPS is SQL Server 2008 R2 Express.
Update:
I have tried to disable the firewall on both my laptop and VPS to see if it is a firewall issue. This made no difference to the error message.
Another Update:
Having now been able to install SSMS (I installed directly from the website rather than using the WPI), I have been able to check that the server is configured to allow remote connections (I went to SSMS, connected to the SQL Server instance, right-clicked on the connection, clicked Properties, went to the Connections tab. "Allow remote connections to this server" is already ticked).
SOLUTION
Thanks to everyone for helping me get to this solution! I've finally managed to get it to work! I followed Filip De Vos's advice and opened the ports in the Firewall on my VPS and then I received a different error message. This led me to investigate further and I found that I was using the wrong credentials to login! So I've set a password for the sa user and I've managed to login using that! Thanks again!
To enable mixed authentication you can change the following registry key:
HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\LoginMode
Update the value to 2 and restart the Sql Server service to allow mixed authentication. Note that MSSQL.1 might need to be updated to reflect the number of the SQL Server Instance you are attempting to change.
A reason for connection errors can be a virus scanner installed on the server which blocks sqlserver.exe.
Another reason can be that the SQL Server Browser service is not running. When this service is not running you cannot connect on named instances (when they are using dynamic ports).
It is also possible that Sql Server is not setup to listen to TCP connections and only allows named pipes.
In the Start Menu, open Programs > Microsoft SQL Server 2008 >
Configuration Tools > SQL Server Surface Area Configuration
In the Surface Area Configuration utility, click the link "SQL Server
Configuration Manager"
Expand "SQL Server Network Configuration" and
select Protocols.
Enable TCP/IP. If you need Named Pipes, then you can
enable them here as well.
Last but not least, the Windows firewall needs to allow connections to SQL Server
Add an exception for sqlserver.exe when you use the "Dynamic Port" system.
Otherwise you can put exceptions for the SQL Server ports (default port 1433)
Also add an exception for the SQL Server Browser. (udp port 1434)
More information:
How to: Configure a Windows Firewall for Database Engine Access
Server Connectivity How-to Topics (Database Engine)
As a last note, SqlLocalDB only supports named pipes, so you can not connect to it over the network.
In addition to configuring the SQL Server Browser service in Services.msc to Automatic, and starting the service, I had to enable TCP/IP in: SQL Server Configuration Manager | SQL Server Network Configuration | Protocols for [INSTANCE NAME] | TCP/IP
Launch SQL Server Configuration Manager on your VPS.
Take a look at the SQL Server Network Configuration. Make sure that TCP/IP is enabled.
Next look at SQL Server Services. Make sure that SQL Server Browser is running.
Restart the service for your instance of SQL Server.
Open the SQL Server Configuration Manager....
2.Check wheather TCP and UDP are running or not....
3.If not running , Please enable them and also check the SQL Server Browser is running or not.If not running turn it on.....
Next you have to check which ports TCP and UDP is using. You have to open those ports from your windows firewall.....
5.Click here to see the steps to open a specific port in windows firewall....
Now SQL Server is ready to access over LAN.......
If you wan to access it remotely (over internet) , you have to do another job that is 'Port Forwarding'. You have open the ports TCP and UDP is using in SQL Server on your router. Now the configuration of routers are different. If you give me the details of your router (i. e name of the company and version ) , I can show you the steps how to forward a specific port.
I had the same issue where my firewall was configured properly, TCP/IP was enabled in SQL Server Configuration Manager but I still could not access my SQL database from outside the computer hosting it. I found the solution was SQL Server Browser was disabled by default in Services (and no option was available to enable it in SQL Server Configuration Manager).
I enabled it by Control Panel > Administrative Tools > Services then double click on SQL Server Browser. In the General tab set the startup type to Automatic using the drop down list. Then go back into SQL Server Configuration Manager and check that the SQL Server Browser is enabled. Hope this helps.
Disable the firewall and try to connect.
If that works, then enable the firewall and
Windows Defender Firewall -> Advanced Settings -> Inbound Rules(Right Click) -> New Rules -> Port -> Allow Port 1433 (Public and Private) -> Add
Do the same for Outbound Rules.
Then Try again.
I recently upgraded from SQL 2008 R2 to SQL 2012 and had a similar issue. The problem was the firewall, but more specifically the firewall rule for SQL SERVER. The custom rule was pointed to the prior version of SQL Server. Try this, open Windows Firewall>Advanced setting. Find the SQL Server Rule (it may have a custom name). Right-Click and go to properties, then Programs and Services Tab. If Programs-This program is selected, you should browse for the proper version of sqlserver.exe.
If you have more than one Instances... Then make sure the PORT Numbers of all Instances are Unique and no one's PORT Number is 1433 except Default One...
Open SQL Server Configuration Manager.
Click SQL Server Services, on the right side choose the server you've created during installation (by default its state is stopped), click once on it and a play button should appear on the toolbar. Click on this play button, wait til its state turns to "Running". Now you're good.
Open SQL Server Management Studio; switch the "Server Type" to "Database Engine" and "Authentication" to "SQL Server Authentication". The default login is "sa", and the password is the password that you chose on creating the server. Now you're good to work.
In my case the problem was caused by the inconsistency between computer names. In system settings my computer was named with some long name, but apparently the name used for some certain communications was trimmed.
I changed the name in the settings to a shorter one and it worked.
I had built both a console app and a UWP app and my console connected fine, but not my UWP. After hours of banging my head against the desk - if it's a intranet server hosting the SQL database you must enable "Private Networks (Client & Server)". It's under Package.appxmanifest and the Capabilities tab.Screenshot
Before download the last version and update your sql server to fix errors of TLS 1.2 on Sql Server 2012. For more information, check here.

Can't connect to SQL Server 2008 - looks like Shared Memory problem

I am unable to connect to my local instance of SQL Server 2008 Express using SQL Server Management Studio.
I believe the problem is related to a change I made to the connection protocols. Before the error occurred, I had Shared Memory enabled and Named Pipes and TCP/IP disabled. I then enabled both Named Pipes and TCP/IP, and this is when I started experiencing the problem.
When I try to connect to the server with SSMS (with either my SQL server sysadmin login or with windows authentication), I get the following error message:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
Why is it returning a Named Pipes error? Why would it not just use Shared Memory, as this has a higher priority order in the list of connection protocols? It seems like it is not listening on Shared Memory for some reason?
When I set Named Pipes to enabled and try to connect, I get the same error message.
My windows account is does not have administrator priviliges on my computer - perhaps this is making a difference in some way (as some of the discussions in this post about an "SuperSocketNetLib\Lpc" registry key seems to suggest).
Had the same problem. Here is what solved it for me:
Open SQL Management Studio
Connected through the admin account I used to setup the instance
Selected the server from Object Explorer
Right mouse click properties
Server properties opens
Go to Security
Changed it from Windows Authentication mode to SQL Server and Windows Authentication Mode
I didi everything google teaches and can't connect with TCP/IP successfully. Then I do these steps to make it work in my home computer:
step 1. Enable TCP/IP in SQL Server Network Configuration for your DB instance.
step 2. Choose properties of TCP/IP and click IP Addresses tab.
step 3. Inactive all IP address except 127.0.0.1.
step 4. Set TCP Port to 1433 in 127.0.0.1 and IPALL.
step 5. Restart sql server service.
step 6. Connect it with TCP/IP using '127.0.0.1\SQLEXPRESS,1433' in Toad for SQL Server freeware, it works!
step 7. Connect it with same server string in php, it works!
step 8. If you need read Chinese string into php program as I am, download MS SQL Server driver for PHP(Believe me, don't even try php_mssql stuff, it'll drive you crazy with Chinese data). For PHP 5.2x, use ts_VC6 version. For 5.3X, use ts_VC9 version (especially when in Win7).
step 9. Edit php.ini (For Appserv, it's under C:\Windows7; for WAMPserver 2.2, it's under c:\wamp\bin\php\php5.3.8), find extension=... line groups. Add 'extension = specific sql erver driver dll filename you are to use.
step 10. Unzip the file downloaded in step 8 and copy the specific dll (or copy all) to php extension directory (you can find it in php.ini's extension_dir=... line). For Appserv, you better copy it to c:\windows\system32, too(Don't ask me why?).
step 11. restart apache service of Appserv or restart Wampserver.
Now you can use TCP/IP to connect with SQL Server 2008 and you can read utf-8 string (in my case) into php program correctly.
Hope this helps those who are deperately looking for this solution, as i am.
Since now you cannot connect to SQL Server to disable named pipes, you have to force a TCPIP connection.
Here's how:
click on START / RUN then run the cliconfg.exe utility. In this, create an alias for your server (you can use the same name) and put the default for TCPIP
That should force TCPIP over Named Pipes and maybe get you connected.
Try connecting to the alias name that you used in CliConfg and it will now connect using TCPIP.
I had this exact same problem. I'd try connecting as ASHWHVM004\SQLEXPRESS and I'd get a connection failed message. If I explicitly requested Shared Memory, it'd work fine. Shared Memory, Named Pipes, and TCP/IP were all enabled.
I seemingly "fixed" it by doing the following:
I opened up Sql Server Configuration Manager and drilled down to SQL Server Network Configuration > Protocols for SQLEXPRESS.
I disabled everything except Shared Memory.
I restarted the SQLEXPRESS service instance and tried connecting as before. It worked fine.
I enabled TCP/IP and Named Pipes and restarted the SQLEXPRESS service instance and tried connecting as before. It worked fine.
Either I did something else during this process to fix it that I don't recall, or the act of disabling and re-enabling caused some twiddly bit to get flipped back the right way.
Good luck!

Trouble logging in to SQL2008

I recently installed SQL2008 and am having trouble logging in from another application. I have set the security to shared authentication and have specified a password for the SA login. I am able to log in using SA and password from the management studio and also from command prompt using the osql command, but when trying to log in from third party software (specifically, WhereNet VSS) I get the popup "The SQL Instance Name or login information is not correct. Please try again."
Any suggestions? Unfortunately I cannot install the software until I can successfully log in to the SQL server so it is critical that I get past this ASAP.
Thanks,
Joseph
Did you enable remote connections to your SQL Svr instance (see Server Properties, Connections)? Also, make sure the Windows (or proprietary) firewall isn't interfering w/ connectivity.
Other than allowing remote connections from SQL Server Instance properties --> connections - did you configure remote connections from SQL Server Surface Area Configuration tool? If not you might wanna play with those options to enable remote connections over TCP/IP and/or named pipes.
Also - did you check from the Configuration Manager Tool if TCP/IP properties are properly configured (TCP port properly set, etc.)
Did you try to do the same stuff on another machine and see if with the same settings it works?

SQL Server Browser showing only hostname, not instance name

I just setup a new Windows Server 2008 machine with an instance of SQL Server 2008 Express. The SQL Browser service does not appear to be working correctly. In Management Studio, browsing for servers shows the hostname of the new server, but not the instance name. When you choose the hostname form the list it doesn't connect. But I can connect manually by typing the hostname\instancename combination.
update 1:
The browser service is running, and I have tried it with several different accounts, including domain administrator which is a bad practice, but I tried anyway for troubleshooting purposes.
I have tried punching the appropriate holes in the firewall, and also completely turning the firewall off.
This is running on a Hyper-V, Windows Server 2008 32 bit guest, which is on a Windows Server 2008 64-bit host. I have done this before (without issues) on this same host, but with SQL 2008 Standard instead of Express.
When I browse for the server in SSMS(Express) on the SQL Server machine, it works fine and shows the whole instance name. When I browse for it on a remote machine (on the same intranet) with SSMS (standard) it just shows the host name.
update 2:
Followed the packets as suggested and found the following
The client sent the broadcast as expected and received correct responses from other SQL Servers on the same network.
The server received the broadcast but did not send a response.
Considering these results, I wonder why the host name ever appears in the client list in the first place. It shouldn't show up at all, right?
update 3:
Spent an hour and a half on the phone with Microsoft support. I learned a few things, but the problem is not yet solved. It was suggested that I try installing an instance of SQL Standard on the same machine. I did that and the new instance exhibits all the same symptoms. The hostname shows up in the browse list only once, not once for each instance.
update 4:
Stackoverflow chose an answer for me thanks to the bounty system, but this question is not answered. Today I tried moving the whole VM to a different host server - everything is exactly the same. The hostname still appears in the browse list, without the instance name.
update 5:
Confirmed that Hyper-V Integration Services are installed on the guest (SQL) server.
check that the browser service is running, it's not turned on by default.
UPDATE1: See if you can install Network Monitor/Wireshark to do a network trace on the SQL Server to see if it's receiving the broadcasts and sending responses. I think this is your best option in troubleshooting this issue. According to MSDN the service uses UDP port 1434, so this is the traffic to watch.
UPDATE2: Does the server have multiple IP's? according to this MSDN article the Windows Server 2008 firewall has issues responding to SQL Browser service broadcasts, even with rules allowing packets through.
I tend not to rely on browsing. You'll get inconsistent results because browsing sends out a broadcast udp/1434 packet and waits for responses back. However, since you are able to connect remotely via SERVERNAME\INSTANCENAME, that aspect of the SQL Browser service is working. If it wasn't, you wouldn't have been able to connect. With that said, to troubleshoot the browsing portion:
Have you tried stopping and restarting the SQL Browser Service?
Have you tried stopping and restarting the instance if that didn't work?
To completely troubleshoot this, unfortunately, you'd have to do packet traces.
Sounds like the browsing service is messed up somehow...
I don't know if you can temporarily take this SQL Server down temporarily. But if so, you may want to try this:
Uninstall all SQL\instances completely.
Run the install of SQL Express 2008
Create a default instance during install (Not a named instance)
Run the installer again and create the default named instance (SQLExpress)
Try connecting to the named instance again. If it works, you can remove the default instance.
I had the same issue in a VM. After shutting down the Firewall it worked.
I just had this same issue. I was not able to see Instance Names in the SSMS Network Servers tab. It turned out that I had set up Hyper-V and created an Internal Network on my local machine. That network was identified as a Public/Guest Network and the Windows Firewall was ENABLED for it, even though my Domain setting has the Firewall DISABLED. Once I disabled that guest network on my computer I could see all the instances.
Machines:
Physical SQL Server 2014 Ent
Windows 8.1 laptop running Hyper-V

Resources