211

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?
desertnaut
  • 57,590
  • 26
  • 140
  • 166

15 Answers15

179

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

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
  • With SSMS 11.0.3128.0 this does not work. Did it get nixed because the behavior led to poor UX? – JoeBrockhaus Jan 20 '14 at 16:08
  • 9
    @JoeBrockhaus 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). – Trisped Sep 30 '14 at 17:34
  • 8
    Seriously? Why didn't I try that first? Haha. For anyone interested, I can confirm this works in SSMS 2014. – Jargs Nov 15 '14 at 05:08
  • 4
    Works on 2016 as well. Thank you! I had an incorrect cached username and this fixed it. – Charl Jan 12 '17 at 14:51
  • Really nice solution. Works like a charm. – slashCoder Mar 28 '17 at 15:13
  • Works on 2014. Thank you – Esat ARSLAN Feb 27 '19 at 13:13
  • 1
    Not sure how I feel about the "pointing the cursor" to select the target of the Delete key, but thanks, it works. – linhartr22 May 10 '19 at 17:29
  • 1
    @linhartr22 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. – Aaron Bertrand Mar 12 '23 at 12:55
136

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
Hardik
  • 3,038
  • 2
  • 19
  • 31
  • 4
    Works with SQLServer 2014 – jomarmen Oct 30 '17 at 14:52
  • 2
    Works with SQL Server 2016 Management Studio. – Poosh Jun 20 '18 at 15:42
  • This is working fine to remove server name history. Is there any way to remove login history? – Yogesh Patel Nov 27 '18 at 07:13
  • 5
    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. – DinoSaadeh Mar 26 '19 at 14:37
  • 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? – rbassett Apr 06 '21 at 12:52
  • 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 manually – rbassett Apr 06 '21 at 13:01
  • 2
    @rbassett 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! – Radderz Nov 15 '21 at 12:34
  • 1
    @Radderz 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. – rbassett Nov 29 '21 at 16:59
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

Raj More
  • 47,048
  • 33
  • 131
  • 198
  • 1
    I open the SqlStudio.bin, the file is big, it seems possible contain other information,what will lose other than connection history? – Cheung Aug 01 '10 at 07:02
  • 4
    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 http://stackoverflow.com/questions/6230159/how-to-delete-server-entries-in-sql-server-management-studios-connect-to-server/6374534#6374534 – Raj More Aug 17 '11 at 12:01
  • 5
    In widnows 7 it's under C:\Users\\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell – Marwan Feb 17 '13 at 12:56
  • 1
    It's a pity, that I can't delete exactly group of server, not all my user settings. – Johnny_D Nov 04 '13 at 20:39
  • 3
    **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. – Aaron Bertrand Jan 12 '17 at 14:52
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/

Community
  • 1
  • 1
Mark
  • 2,926
  • 3
  • 28
  • 31
  • 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! – jaraics May 28 '14 at 15:06
  • @Mark - 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. – Keith Aug 20 '14 at 12:32
  • 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. :) – Jargs Nov 15 '14 at 05:05
  • 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. – Mark Dec 15 '14 at 15:29
  • @Mark This worked perfectly for MSSQL 2008 R2 Management Studio. I'm glad I kept reading through the comments/answers and found this one. – HPWD Feb 11 '15 at 20:15
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
Damian Powell
  • 8,655
  • 7
  • 48
  • 58
  • 6
    And for SSMS 2014, it is now at `c:\Users\\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin` but I'm guessing that was kind of obvious. – charlie Jun 06 '14 at 15:10
  • quicker to reach using: `%appdata%\Roaming\Microsoft\ SQL Server Management Studio\11.0\SqlStudio.bin` – iDevlop Sep 05 '16 at 08:02
  • 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 and inside of there is that has each connection if you are looking to remove a specific connection. – Orin Feb 22 '23 at 16:25
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.

Pang
  • 9,564
  • 146
  • 81
  • 122
Varus
  • 179
  • 2
  • 4
14

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

%UserProfile%\Microsoft\Microsoft SQL Server\100\Tools\Shell\
  • This doesn't help. The file will be recreated with the same users in it. – nima Sep 24 '12 at 10:53
  • 2
    @nima you may need to close SSMS before deletig the file. Also see my answer for a way to delete individual items. – Mark Sep 26 '12 at 22:29
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.

Tommy Grovnes
  • 4,126
  • 2
  • 25
  • 40
Chintak Chhapia
  • 751
  • 7
  • 10
  • 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?) – JoeBrockhaus Jan 20 '14 at 16:07
  • 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. – Chintak Chhapia Feb 19 '14 at 10:56
  • 1
    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. – JoeBrockhaus Mar 04 '14 at 20:32
  • 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. – Chintak Chhapia Mar 27 '14 at 07:05
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.

Pedram
  • 6,256
  • 10
  • 65
  • 87
  • 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.xml – rbassett Apr 06 '21 at 13:03
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.

Community
  • 1
  • 1
Tomas
  • 69
  • 1
  • 1
5

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

DEL /S SqlStudio.bin
ggponti
  • 395
  • 5
  • 9
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
abatishchev
  • 98,240
  • 88
  • 296
  • 433
Mido-Egypt
  • 29
  • 1
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

sergiommaria
  • 117
  • 1
  • 9
0

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

Peter
  • 51
  • 1
  • 2
  • 10
-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.
Pang
  • 9,564
  • 146
  • 81
  • 122
Pete
  • 179
  • 1
  • 2
  • 7