I have a problem at my company where the SQL Server names that were set up are really inconsistent and i'm trying to fix it while redoing these servers. I basically have 3 servers with different names and I'd like to use the one that just requires the server name. For example:
Server 1:
ServerName: MDGSQLP01\MDG
InstanceName: MDG
Server2:
ServerName: MDGSQLP02
InstanceName:
Server3
ServerName: MDGSQLP03/MDGSQLP03
InstanceName: MDGSQLP03
So when I connect to all of these I have to use the server name obviously. I would rather that these all be named like Server2 so my connection string is always just, MDGSQLP0_ . Anyone know how this is done? Do I need to uninstall the server to be able to drop the instance name?
To connect to all servers in a consistent way, instead of changing the instance name you can change the port number, so they all have the same value. If you make this new value the default port number (1433) you can connect without having to specify instance name or port number.
Open SQL Server Configuration Manager.
Select SQL Server Network Configuration.
Select the instance to configure.
Right click TCP/IP protocol .
Select Properties.
Select IP Addresses tab.
Change the port number to 1433.
NB: This means you can't use dynamic port numbers (which use the SQL Browser service to resolve a request using instance name to the relevant port number). This has a few disadvantages:
Port sniffers are more likely to spot the instance if running on a default port.
If some other application on the server uses this port before SQL does, SQL is not able to find a free alternative port to use.
However, these issues are generally not a significant concern.
Related
I am using SQL server express 2014. I used the below connection string as server name in SQL Express. but it failed.
[my servername],1433\SQLEXPRESS
In sql server 2012, I can connect the connection string in the format of [my servername],1433
Could you please anyone suggest how do I specify a port number in a connection string for SQL Express server?
First of all, if you did not change the port manually, SQLEXPRESS is NOT listening on 1433 that is reserved for default instance, it uses dynamic port that you can find in Configuration Manager or in SQL Server error log.
Here you can see both methods with pictures: Identify SQL Server TCP IP port being used.
Second, there is no need to specify instance name + port, in fact if you do it, instance name is effectively ignored, so when you use
[my servername]\SQLEXPRESS,1433
you'll try to connect to
[my servername],1433
That is because to connect to server you need to know it's address and port, so or you use
myServer,port
or you use
myServer\instanceName
In the first case the underlying network library has all information it needs to connect(IP + port). In the second case SQL Server Browser need to be started.
It's SQL Server Browser that will comunicate instance port given instance name.
When your connection string contains both instance name and port, only port is used and instance name is ignored, so if you use a wrong port, even with correct instance name you cannot connect.
put the port after the instance name, like:
[my servername]\SQLEXPRESS,1433
Have in mind that if SQL Express is the only SQL server in this PC you can also use:
[my servername],1433 or [serverIP],1433
I want to access my database over network. It gives error:
Error: Cannot Connect to 192.168.0.2\SQLEXPRESS
I enabled the TCP/IP from SQL Configuration.
I turn off the firewall.
I allow SQL Server Authentication and Windows mode.
and I can ping to the ip-address.
Why I am not able to connect to database?
Try to connect by specifying 192.168.0.2,1433 , here 1433 is port.
Probably is a server configuration problem. Try as follow.
On the server, open SQL Server Configuration Manager
Open SQL Server Network Configuration on the left panel and select Protocols for YOURSERVERNAME.
On the right panel double click on TCP/IP and be sure that Enabled is set to Yes.
Open the tab IP Addresses and set as Yes the Active and Enabled selection boxes where the IP Address is 192.168.0.2.
You're probably using a wrong instance name. If you want to connect to a default one i.e. MSSQLSERVER use either dot (.) or a machine name or an IP address as a sever name.
If you are not sure what is the name of your instance just run SQL Server Configuration Manager. You can find it in Start menu. Then select SQL Server Services and there you should find something like SQL Server (NAME_OF_YOUR_INSTANCE).
It is also worth reading this article and this question.
I have two instances of SQL Server on my local machine. They both listen to separate ports. The first instance that I installed runs on the default port: 1433. I have set the other to listen to port 1434.
My application is using some old shared code that we have here to generate the connection string. So until now I didn't really know what was happening there. Due to a new requirement I found myself needing to examine the connection strings that I'm using to connect to the SQL Server.
What I found that was that for the connection string be built to connect to each of the SQL instances did not include Network Library, nor did they include the port number as part of the Data Source. The Data Source was just set to <Server Name>/<Instance Name>. I did find in the MS documentation that if the Network Library is not included then it is treated as (local), but it doesn't really explain how (local) is treated.
So my question is why is a connection string in this format able to connect to the SQL Server instance that runs on the non-default port? will this only work if the instances are on the local machine, or local network? Can I put <ip>/<sql instance> without the port if the server is remote?
I just need some clarity on how this works, and when is the port number needed and when it is optional as I'm trying to make my connection UI as simple as possible for our users.
There is such a thing called "SQL Server Browser Service":
http://technet.microsoft.com/en-us/library/ms181087(v=sql.105).aspx
It is intended to provide clients with information about sql server instances, ports. It actually listens on UDP port 1434.
With this service turned off you will still be able to connect to the instance, but you need to specify TCP/IP port.
I have two instances of SQL Server on my local machine. They both listen to separate ports. The first instance that I installed runs on the default port: 1433. I have set the other to listen to port 1434.
Just out of curiousity, why don't you just have them setup as named instances both running on the default of 1433 ?
As for why it works, if you search for SQL Configuration in your start menu, you'll find a screen similar to this.
Sql Server supports a number of different ways of connecting. TCP/IP is one way (ie IP addresses and ports) but it also supports a Shared Memory connection if you're on the local machine. that is, if you SQL Server executable, and management studio/client are also on the same machine.
At a guess I'd say it defaults to shared memory when you specify local and therefore you don't need to specify the port.
You could test this out by temporarily disabling shared memory in the above config, and see if your (local)\InstanceName stops working.
I have a named instance of SQL Server Express that I want to make it visible on the network. I was able to do it, but other machines can only connect to it specifying the port number, even though it is the default port.
For example, other machines can connect to mine using (1433 is the default port for SQL Server):
<hostname>\<instancename>,1433
But other machines can't connect without using the port:
<hostname>\<instancename>
I checked the Firewall (other people can connect specifying the door), and SQL Server Browser is running (I don't fully understand but I read that it make some difference).
Any tips? Thanks.
If you're running on the default port try connecting to the host name without the instance name attached.
If you have named instances and don't want to declare your ports then you need to ensure that SQL Server Browser is running. go and check "sql server configuration manager"
I have two development teams, that come from different groups.
Group A develops against a local default instance of Sql Server 2008 R2;
Group B develops against a local named instance of Sql Server 2008 R2.
Is there a way to setup an alias such that both groups are coding against the same name? As it stands right now we have a war of Connection Strings as group B changes (local) to ./DEV and group A changes it back again?
In SQL Server Configuration Manager, under the SQL server native client configuration section there is a subsection called "aliases" you can add an alias into here that points to your named instance. You just use the alias as if it is the default instance on a server with the name of the alias. We use this exact model and have only one connection string that points to a standard alias. Each developer has the same alias name pointing to their own instance.
Aliasing to a Local SqlExpress Instance
To expand on Ben's answer, I had the specific requirement to alias a connection string pointed at a specific Server Instance, and instead re-route this to our local developer Sql Express instances, i.e. to alias from:
SomeServer\SomeInstance
to
.\SQLExpress
This proved somewhat tricky until I found this link here. My Sql Express instance was running on the standard port 1433 (i.e. adapt to suite)
Enable TCP/IP for SqlExpress
Since aliasing is done via TCP/IP ports, TCP/IP protocol must be enabled. (Opening SqlExpress for remote access isn't necessary if you are working locally).
Using Under Sql Server -> Configuration Tools -> Sql Server Configuration Manager:
At the same time, set the Listen All property to Yes.
Enable LocalHost IP's
Ensure that both IPv4 (127.0.0.1) and IPv6 (::1) localhosts are active and enabled.
On each IP's, Leave the Dynamic Port at zero (as the name suggests, the port will be allocated dynamically). The IPAll Dynamic and TCP Ports are then used globally.
You'll need to restart the MSSQLServer / SqlExpress service to effect the change.
Creating Aliases (32 and 64 bit)
Under the Sql Native Client xx Configurations, this requires simply adding the alias "From" Server\Instance as the Alias Name and the actual server + instance as the Server (i.e. my local SqlExpress instance). I was able to connect via both port 1433, or the dynamic port on IpAll (9876), although saw no reason to use the latter. The aliases must be done for both 32 and 64 bit client configurations.
You should now be able to connect using the aliased SomeServer\SomeInstance via SSMS.
Other Notes
Since I was aliasing to a local instance, I did NOT have to add an alias for the from host, SomeServer to a DNS or LocalHosts. This will likely be required however if you are aliasing to a remote server (plus I guess some other security headaches)
I did not need to have the Sql Browser service running.
So it would seem that the Sql Client configuration takes care of the substitution prior to any network or security steps.
Personally, I'd make them all use the same box.
That said, you can set local aliases per developer's box using SQL Server Client tools.
Anything IP address or server name based (such as hosts file or DNS) will fail because instance names (and ports used) are different