Rename server name in SQL Server 2014 and management studio? - sql-server

I use management studio and SQL Server. How to change server name from (LocalDbs)\MSSQLLocalDB to localhost? When I connect to server in connection string I want to call: server='localhost

I believe, it's not good idea to change named instance to default instance as it might conflict with existing default instance, and considering consequences. However, \InstanceName is really concern for the connection string, you could have custom port assigned to that SQL Instance so that your connection string would be server=localhost,portnumber.
Please have a look at this answer at DBA.StackExchange to learn more on connecting SQL Server with custom port and how to change the port#
If you still have concern to use port number in connection string server=localhost,portnumber. My advise is to restore the database on SQL default instance (need to be installed if not existed already), then you could re-direct the application to communicate with default SQL Instance, this case your connection string would look like server=localhost
You could do following, if you want rename the Server in any case:
sp_dropserver <old_name>;
GO
sp_addserver <new_name>, local;
GO

Related

SQL server default instance with a different port

One of our clients have SQL server default instance running on a non-default port. So, the connection string from our application should be servername,1234.
They don't want to create aliases on the MS SQL server.
Is there any different way our application can connect to it?
It is a default instance, so can I use servername\MSSQLServer
Thank you!
SQL Browser does not support connecting to a default instance with
servername\MSSQLServer
They don't want to create aliases on the MS SQL server.
That wouldn't help anyway. Aliases are created on the client computer, not the SQL Server.
See Create or Delete a Server Alias for Use by a Client

Replication Server Name issue in SQL Server 2012

I am facing server name problem in SQL Server 2012. When I click on configure distribution I get an error:
Unable to connect to server. Specify the actual server name.
I changed my server name and restarted the services but unable to connect through new server name.
Basically, I am doing this on local domain based server.
Kindly suggest a suitable solutions.
After you rename a SQL Server machine, you will also need to rename the SQL Server instance itself using:
sp_dropserver <old_name>;
GO
sp_addserver <new_name>, local;
GO
For more information, see Microsoft's article called Rename a Computer that Hosts a Stand-Alone Instance of SQL Server.
I think what your probably finding is that changing the Windows server hostname doesn't actually change the original SQL Server instance name which still gets used for certain services. Run the following on the DB engine:
SELECT ##SERVERNAME
You'll probably find a different value to what your expecting from the OS.
There isn't really a solution to this that I'm aware of without re-installing SQL Server on the newly named box.
Also be careful with names that exceed to the 15 character NetBIOS limit.

Microsoft SQL Server IP/server login

I have installed many SQL Server setups but I want to know how to install SQL Server without an instance name i.e. i want to connect to SQL Server with IP or server name only.
Installing an instance and connecting to an instance of SQL Server are two different things.
Every time you attempt an SQL Server installation you have to specify an instance (create a new one or select an existing one)
Connecting to an instance is a different thing.
For example if you want to connect to an instance through MS Management studio without writting the name of the instance you can define the connection in following manner:
ComputerName\IP,port
e.g:
MyPC\192.168.1.1,1433
In order to do this you need to install SQL Server as the default instance on the machine. When it is set as the default instance you no longer need to specify an instance name when connecting to it.

Configure a SQL Server Instance as (local)

Each member of our development team has a copy of our application's database running on a local version of SQL Server 2008 Enterprise with SP1. Everyone is able to access the database by specifying their server and instance name in their web.config file, but to best share the developer version of our web.config file, we have standardized on making connections strings generic by using integrated security and setting server property to (local). This strategy is working fine for the majority of our 64-bit Windows 7 machines but in few cases (local) isn't recognized. We have compared settings via the SQL Server Configuration Manager (namely ensuring that the named pipes protocol was enabled) and we've tried setting the "(local)" alias via SQL Server Client Network Utility, but we haven't any luck. What needs to be done in order to use (local) in our connections strings?
Trying changing the Pipe Name for your instance to "\.\pipe\sql\query".
You can find that setting by starting SQL Server Configuration Manager, and navigating to SQL Server Network Configuration > Protocols for (Instance Name) and right-clicking on Named Pipes and selecting Properties. If Named Pipes is not enabled, be sure to enable it before restarting the SQL Server service (see comment by #NoahHeldman).
When connecting to the default instance (that is, without an instance name), SQL Server uses the default port of 1433 and the default pipe name of "\.\pipe\sql\query". Changing it back to match should (hopefully) fix it.
Those machines where the database connection as (local) doesn't work is probably that way because during the database installation, the instance name was set to something specific, rather than the default of "default instance". You can change these instance names, which may resolve this issue: http://coderjournal.com/2008/02/how-to-change-instance-name-of-sql-server/.
I think this occurs when you have SQL Server Express already installed and running, and then install SQL Server Developer Edition / Standard / etc....not 100% sure though, but from what I recall, that may be the case.

JDBC connect string for SQL Server cluster

I need to setup a JDBC connection string to SQL Server.
This question is similar to the the C# ADO.Net connection question. This one is specific to JDBC connection strings.
The usual format for the JDBC string is "jdbc:sqlserver://{host}:{port}".
Now, for a SQL server cluster I have a cluster name vvv\iii ({virtual server}{instance name}).
There's no problem setting up an ODBC connection through the "New Data Source to SQL Server" wizard when using the vvv\iii string as the server name. However it seems the JDBC connection string requires a specific host and port.
Is there a way to make a JDBC connect string to a SQL Server cluster?
it turns out that you can use the "instanceName" property within the JDBC string, as documented on the Microsoft Technet page in section "Named and Multiple SQL Server Instances". What worked in my case was the following string for virtual server vvv and database instance name iii:
"jdbc:sqlserver://vvv;instanceName=iii"
When using a SQL Server named instance in a cluster or stand alone environment each SQL Server instance is dynamically assigned a port number on startup. The SQL Server Browser server handles requests to each instance because each server restart could change the port number used by each instance. The first instance to start on a server reboot gets assigned 1433 but there is no guarantee if you have 2 instances that one of them will always get 1433. There are several veriables that affect the startup and recovery time it takes for an instance to start. This can change each time.
That being sad... when connecting to a named instance the jdbc connection string should look like this:
jdbc:sqlserver://server_name/db_name;instance=instance_name
rather than this
jdbc:sqlserver://server_name:1433/db_name;instance=instance_name
note that the default database "/db_name" is optional. If exclued the connection will use the default database assigned to the SQL Server login.
The cluster resource has a host name and a listening port. Use jdbc:sqlserver://{virtualserver}:1433 (or the appropriate listening port if not listening on the default one).
I'd comment Mark Stewart's remark, but the reputation is lacking. My source doesn't mention /db_name and I can't get it to work either. Maybe another case of confused instance names?
Make sure you leave the port definition off as the cluster determine this for you.
So my datasource definition looks like:
jdbc:sqlserver://sqlcluster_hostname\instancename;DATABASENAME=databasename;sendStringParametersAsUnicode=false;SelectMethod=direct
I ran into this issue while trying to setup a Railo datasource to connect to MSSQL cluster.
Slightly off topic ... The standard Railo datasource MSSQL driver option sets the port to "-1" if you leave the port field empty however if you set it to "0" then it removes the port definition altogether and then everything works. But the best way is to choose 'Other - JDBC Driver' to define the JDBC connection string in full as above.

Resources