Captain Kenpachi
Captain Kenpachi

Reputation: 7215

Rename an SSMS DB connection name

The title may be a bit misleading, so let me clarify: I don't want to know how to rename a connection string or db name. What I'm trying to find out is how would I create a friendly label for my database connections in SQL Management Studio?

e.g. I have the following connections:

enter image description here

I want to rename them to something else, e.g. "dev server", "PreProd", "Live", or whatever the case may be. I thought I could easily do this in SSMS, but apparently I can't.

I'm always worried that I may inadvertently make a change on the wrong server and having a nice friendly name will go a long way in preventing it.

Upvotes: 20

Views: 9180

Answers (4)

REEL
REEL

Reputation: 26

I needed to change an item from Server Name list and I found that I could do that in this file %APPDATA%\Microsoft\SQL Server Management Studio\20.0\UserSettings.xml with SSMS 20.2

Upvotes: 1

Fitz09
Fitz09

Reputation: 39

Adding on to James Barnard's answer.

With SSMS 18.7.1 (and maybe earlier versions) you can actually right click the connection in your Object Explorer and select the Register... option. This way you don't have to retype your connection details in the Registered Servers window. SMSS 18.7 server registration steps

Upvotes: 2

James Barnard
James Barnard

Reputation: 336

I've struggled for years with SSMS database connections that don't have friendly names but are stuck with an IP address or a server/database name. You'd think MS would have provided ways for users to manage these by now, but no.

Something you might consider is using registered servers. SSMS 17 (I don't know about earlier versions) has these and I find them easier to use because you name them whatever you want.

Invoke View/Registered servers to show that pane, then expand the Database Engine node. Right-click the Local Server Groups node and then New Server Registration. Fill out the fields putting whatever you want for a name in the Registered server name box, and test the connection. Once it works, click the save button and you're done. Double-clicking the new registered server connection connects you to the database and opens up the object explorer.

I also switched my startup options (Tools/Options.../Environment/Startup) "At startup" choice to "Open empty environment". This brings up the IDE without prompting me to immediately connect to a database.

Upvotes: 20

Captain Kenpachi
Captain Kenpachi

Reputation: 7215

Right, so anyway what you have to do is the following

  1. Get the name of the server the IP address points to. You can do this via the command prompt using nsLookup [ipaddress]
  2. use the name instead of the IP address

Alternatively, if you want to control what the actual displayed name is, you could add an entry for each of the IP addresses in your HOSTS file:

  1. Run any text editor as administrator
  2. browse to c:\windows\system32\drivers\etc (etc is a hidden directory) and open the HOSTS file
  3. for each IP address, add a record like such: 1.2.3.4 MyFancyServerName
  4. You can now use MyFancyServerName instead of the IP Address 1.2.3.4.

Upvotes: 7

Related Questions