How to remove "Server name" items from history of SQL Server Management Studio
Asked Answered
L

15

220

When trying to connect to a server in Management Studio (specifically 2008), there is a field where you enter the Server name. That field also has a drop-down list where it shows a history of servers that you have attempted to connect to.

  1. How to remove an individual item from that history?
  2. How to remove an item from the Login field history for each Server name?
Lug answered 29/6, 2009 at 16:2 Comment(3)
See my answer for a little UI I wrote to do this, I was a little late to the party so my answer is way down the bottom at present.Alodee
Naughty. Next time use incognito mode if you're going to query any dodgy databases.Lorenzen
Install Everything tool , then search the file mru.dat and delete itPurificator
A
190

As of SQL Server 2012 you no longer have to go through the hassle of deleting the bin file (which causes other side effects). You should be able to press the delete key within the MRU list of the Server name: drop-down in the Connect to Server dialog. This is documented in this Connect item and this blog post.

With the drop-down expanded, hover over the item you want to remove, and with it highlighted while the drop-down is still expanded, press the Delete key. (If you have a keyboard with two such keys, use the one that doesn't double as Backspace, common with Mac-centric keyboards.) The drop-down list will redraw immediately and remove the selection:

Before & after removing entry from MRU list

Note that if you have multiple entries for a single server name (e.g. one with Windows Authentication and one with SQL Authentication), you won't be able to tell which one you're deleting. Since it is an MRU list, the order won't change until you make another successful connection, so you can solve this by selecting the item you think is the right one, and checking which credentials pop into the remainder of the dialog once selected. When you've identified the one to delete, then repeat the process above by hovering over that entry in the expanded drop-down list and pressing Delete.

In older versions you could delete the entire list by deleting SqlStudio.bin or mru.dat and letting SSMS re-generate the file, but this was a brute force method - not only did it delete all connection entries, but it blew away other settings, too. To be more surgical, you'd have to figure out how to modify those files correctly, and this is not an easy task (see this and this). In newer versions, you can modify UserSettings.xml - which stores these settings in a much more human readable form.

  1. Close down all instances of SSMS

  2. Navigate to %appdata%\Microsoft\SQL Server Management Studio

  3. Drill into the major version you want to impact, like 18.0 (you may only have one, or you may have to repeat for multiple) - and not the folder with the _IsoShell suffix

  4. Make a backup copy of UserSettings.xml

  5. Open UserSettings.xml with notepad

  6. Find the server entry you're looking for

    It may be a single entry like this, in which case, you can delete the entire <Element> node:

    Example single entry

    Or it may be a compound entry, where you've connected to the same server/instance name in different ways (different authentication methods or different SQL Authentication usernames). In this case, you want to (carefully!) delete just the <Item> of interest. For Windows Authentication it will look like this, where AuthenticationMode will be 0:

    Windows Authentication MRU list item

    And for SQL Authentication, AuthenticationMode will be 1, and you can identify which <Item> to remove by the <UserName>:

    SQL Authentication MRU list item

  7. Save UserSettings.xml and restart SSMS

Artemus answered 12/6, 2012 at 11:50 Comment(6)
With SSMS 11.0.3128.0 this does not work. Did it get nixed because the behavior led to poor UX?Ambush
@Ambush Works with 11.0.5058.0. Just open the drop down, move the selection over the name you want deleted, and press the Delete key. If you have multiple entries you can select the entry so the ComboBox closes, check that it is the one you want, then hit the open button on the ComboBox and press delete (the currently selected entry will be deleted).Samara
Seriously? Why didn't I try that first? Haha. For anyone interested, I can confirm this works in SSMS 2014.Isisiskenderun
Works on 2016 as well. Thank you! I had an incorrect cached username and this fixed it.Hazelton
Not sure how I feel about the "pointing the cursor" to select the target of the Delete key, but thanks, it works.Masquer
@Masquer Technically, you don't have to "point" anything - the down arrow works too for identifying the offending selection. But it does feel hokey and undiscoverable - I'd love to see a right-click option like "Remove this entry from this list." Until then, these are the options we have.Artemus
A
144

Here is the simplest way to clear items from this list.

  1. Open the Microsoft SQL Server Management Studio (SSMS) version you want to affect.
  2. Open the Connect to Server dialog (File > Connect Object Explorer, Object Explorer > Connect > Database Engine, etc).
  3. Click on the Server Name field drop down list’s down arrow.
  4. Hover over the items you want to remove.
  5. Press the delete (DEL) key on your keyboard.

there we go.

Aberration answered 24/2, 2017 at 10:7 Comment(8)
Works with SQLServer 2014Ours
Works with SQL Server 2016 Management Studio.Tnt
This is working fine to remove server name history. Is there any way to remove login history?Hardan
What the hell! I read it and was like WHAT! How would anyone intuitively guess this. I tried and it worked. UX is not a Microsoft strong point.Kotta
Pressing delete on the keyboard with the server selected does not work for 18.8, however I did migrate my settings from 17.X so I wonder if that has screwed it up. Any ideas?Sector
I did find C:\Users\USERNAME\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml which contained the server names which I could remove manuallySector
@Sector Re-read the answer -> Don't select the item you want to delete, instead open the dropdown, hover over the item (without selecting) and then press the DEL key. I've never seen anything like this before, but it works!Cheetah
@Cheetah you are right, I had selected it rather than hovering over, well spotted. However I also have multiple logins for the same server, one of which I wanted to remove and so editing that xml file meant I could remove the login I didn't want whilst leaving the other logins for that server still there.Sector
S
69

For SQL 2005, delete the file:

C:\Documents and Settings\<USER>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat

For SQL 2008, the file location, format and name changed:

C:\Documents and Settings\<USER>\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin

How to clear the list:

  1. Shut down all instances of SSMS
  2. Delete/Rename the file
  3. Open SSMS

This request is registered on Microsoft Connect

Spanish answered 29/6, 2009 at 16:19 Comment(5)
I open the SqlStudio.bin, the file is big, it seems possible contain other information,what will lose other than connection history?Efflux
The file contains user settings - anything that you have customized will be lost. If you have some .Net or Powershell skills, look at this answer #6230659Spanish
In widnows 7 it's under C:\Users\<USER>\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\ShellAlper
It's a pity, that I can't delete exactly group of server, not all my user settings.Moonmoonbeam
PROCEED WITH CAUTION. This doesn't actually do what the OP asked, which was to remove individual items. This blows away all items, and other preferences too.Artemus
A
43

Over on this duplicate question @arcticdev posted some code that will get rid of individual entries (as opposed to all entries being delete the bin file). I have wrapped it in a very ugly UI and put it here: http://ssmsmru.codeplex.com/

Alodee answered 26/9, 2012 at 22:27 Comment(5)
Worked well for me for SSMS 2008 R2 (10.50.1777.0), but to be sure I had overwritten the included DLLs with ones from the SSMS directory. As far as I can tell, all other settings remained intact. Thanks!Overly
@Alodee - Thank you very much. A side note: if you have two servers with the same name, even if they have different login authentication types, and you delete one, it will delete them both.Saucepan
I know this was built for 2008, but in case anyone is interested, I tried this tool on SSMS 2014. I had to change the config file to look in the right directory, and it was able to find the servers in the bin file, but when I clicked on save and then opened SSMS, all of my servers were gone, instead of just the one I deleted. Luckily I backed up my bin file first. :)Isisiskenderun
The binaries are different for 2014 - I haven't done a 2012/2014 version as it is possible to delete server from SSMS. If there was interest I could try and fnd some time to create.Alodee
@Alodee This worked perfectly for MSSQL 2008 R2 Management Studio. I'm glad I kept reading through the comments/answers and found this one.Deaf
H
21

For SQL Server 2012 Management Studio, this file has moved. It is now located at:

C:\Users\<username>\AppData\Roaming\Microsoft\
    SQL Server Management Studio\11.0\SqlStudio.bin
Homeostasis answered 12/6, 2012 at 9:46 Comment(3)
And for SSMS 2014, it is now at c:\Users\<username>\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin but I'm guessing that was kind of obvious.Escalate
quicker to reach using: %appdata%\Roaming\Microsoft\ SQL Server Management Studio\11.0\SqlStudio.binCandlemas
Now located in %AppData%\Roaming\Microsoft\SQL Server Management Studio\18.0. Make a backup of the UserSettings.xml before you modify it. Shutdown SSMS. Open file and look for <Connections> and inside of there is <Element> that has each connection if you are looking to remove a specific connection.Binocular
E
15

Here is an easy way.

Open the connection window, click on the Server name dropdown, and hover over the connection string you want to delete, then press delete.

Exacting answered 11/6, 2019 at 20:32 Comment(0)
A
14

In Windows Server 2008 standard with SQL Express 2008, the "SqlStudio.bin" file lives here:

%UserProfile%\Microsoft\Microsoft SQL Server\100\Tools\Shell\
Advanced answered 21/8, 2009 at 18:5 Comment(2)
This doesn't help. The file will be recreated with the same users in it.Sextant
@Sextant you may need to close SSMS before deletig the file. Also see my answer for a way to delete individual items.Alodee
E
9

In SSMS 2012 there is a documented way to delete the server name from the "Connect to Server" dialog. Now, we can remove the server name by selecting it in the dialog and pressing DELETE.

Equimolecular answered 17/10, 2012 at 6:35 Comment(4)
verified with SSMS 11.0.3128.0 this does not work. Probably got nixed because it clouds the native delete behavior. (The MSDN post makes a point of saying the previous item text will remain in the box after deleting, which is a poor UX decision. What if I just wanted to delete the text, and not the saved entry?)Ambush
In my case, I have 11.0.3000.0 version and It works fine. Just you need to click drop down, select server and then click delete. Yes, it's little confusing.Equimolecular
where do you 'click' delete? There is no delete button in my UI. Still, even just hitting the delete key simply deletes the text in the ComboBox, and the entry remains in the dropdown.Ambush
Sorry my mistake, instead of "click delete", I should have written "press delete key". There is no button for delete, you need to press Delete key from Keyboard.Equimolecular
S
9

Delete the file from above path: (Before delete please close SSMS)

File location path for the users of SQL Server 2005,

C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat

File location path for the users of SQL Server 2008,

Note: Format Name has been changed.

C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin

File location path for the users of Server 2008 standard/SQL Express 2008

C:\Documents and Settings\%USERNAME%\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin

File location path for the users of SQL Server 2012,

C:\Users\%USERNAME%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin

File location path for the users of SQL Server 2014,

C:\Users\%USERNAME%\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin

Note: In SSMS 2012 (Version 10.50.1600.1 OR Above), ow you can remove the server name by selecting it from dropdown and press DELETE.

Sequela answered 14/10, 2015 at 5:32 Comment(1)
For SQL Server Management Studio 18.8 I found the server settings in C:\Users\USERNAME\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0\UserSettings.xmlSector
B
6

File SqlStudio.bin actually contains binary serialized data of type "Microsoft.SqlServer.Management.UserSettings.SqlStudio".

Using BinaryFormatter class you can write simple .NET application in order to edit file content.

Bassesalpes answered 3/5, 2010 at 8:40 Comment(1)
See my answer for a simple UI that I have wrapped around this code.Alodee
U
5

From the Command Prompt (Start \ All Programs \ Accessories \ Command Prompt):

DEL /S SqlStudio.bin
Upchurch answered 23/10, 2009 at 14:51 Comment(0)
M
2

For Windows Vista and SQL Server 2005,

Delete this file, or open it with the Notepad and clear the server names that you want Clear from the history

%UserProfile%\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
Milksop answered 23/10, 2009 at 23:32 Comment(0)
R
2

This is the correct way of doing it http://blogs.msdn.com/b/managingsql/archive/2011/07/13/deleting-old-server-names-from-quot-connect-to-server-quot-dialog-in-ssms.aspx

Remington answered 4/7, 2015 at 12:39 Comment(2)
Above is the easy supported way and works with 2012 and above.Lp
Link is broken now.Asyllabic
P
0

C:\Users\\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell

Penknife answered 26/9, 2013 at 18:32 Comment(0)
C
-1

Rather than deleting or renaming this file:

  1. Close SQL Server Management Studio.
  2. Find the appropriate file (see the other posts).
  3. Open the .bin in a text/hex editior like NotePad++.
  4. Search for the name of one of the servers and identify the line number.
  5. Make a copy of the .bin/.dat file.
  6. Delete that line. Make sure you delete the entire line, it's possible if you have many the line could wrap.
  7. Open SQL Server Management Studio. Your dropdown will be blank.
Corrigendum answered 31/1, 2014 at 18:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.