Change color scheme for Admin account in SSMS

  • I was reading one of Brent Ozar's posts about SSMS, and he was talking about "never use the sa/admin account unless you need to", so I was wondering if there is a way (I know there is) to change the background color or the color of the window for just the SA/admin account, so I know if I'm playing with fire so to speak. I was looking in the settings for SSMS, and although I thought I changed the color scheme for one account, I still get the standard blue.

    What stupid thing am I missing?

    Thanks!

  • As far as I know, you can't change the color of SSMS based on who you connect as, but you can change the status bar color:

    https://www.sqlshack.com/how-to-set-custom-colors-in-the-ssms-status-bar/

    And, with a quick test on SSMS version 17.9.1, it seems to apply to the user you set in the registered servers, not just the instance name you pick.

    Something to note though - the instance name must match exactly what you enter when you connect.  What I mean here is if you use a SQL alias to connect of "admin" for example and you make the registered server for "admin", it will work fine.  BUT if you have an alias, but make the registered server for the non-admin name ("adminserver\admin, 4321" for example), the color scheme will not be applied.

    I am not sure of any way to change the background color of the window based on who you log in as.  I believe that the editor window colors are a windows user specific setting, not a SQL session specific setting.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • I believe that the editor window colors are a windows user specific setting, not a SQL session specific setting.

    =(

    Drat. So at least I might not be as dumb as I had originally thought. I guess the moral of the story is to log out of the SSMS instance with elevated privileges as soon as you're done with it.

  • pietlinden wrote:

    I was reading one of Brent Ozar's posts about SSMS, and he was talking about "never use the sa/admin account unless you need to", so I was wondering if there is a way (I know there is) to change the background color or the color of the window for just the SA/admin account, so I know if I'm playing with fire so to speak. I was looking in the settings for SSMS, and although I thought I changed the color scheme for one account, I still get the standard blue.

    What stupid thing am I missing?

    Thanks!

    The thing you may be missing is that the account with the name of "sa" should be disabled and never used by individuals. If you're talking about some other account with "sysadmin" privs, then just change the color when you login to SSMS with that account.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • It's not exactly what you ask, but Redgate SQL Prompt allows you to create color for tabs. I usually put RED to all environments where I need to be more careful.

  • Oh, so it's not an "out of the box" thing. I was watching one of Brent Ozar's videos on SSMS, and I thought it was. Thanks! Might have to splurge...

    That's a helpful answer - I was trying to get it to work just in SSMS, but maybe it's not possible.

  • This isn't out of the box. SQL Prompt does this, as does SSMS Tools Pack, but you pay for both.

    Disclosure: I work for Redgate, developer of SQL Prompt.

  • Steve, can the SQL Prompt colorize by user?

  • It's by the instant/db, but the scope is per SSMS install. So I can color my dbs/instances separate from how you do it.

  • I am pretty sure that SQL Prompt (at the moment) cannot colorize the tab based on the SQL login (Windows or SQL).  That is, if you log in as "sa" or log in as "RedGate\SteveJones" you will get the same color scheme.

    What you CAN do is colorize the status bar (the yellow bit near the bottom that has "Query executed successfully" and the server/instance you are connected to) and this can be colorized based on instance AND partially by user.  I say partially as it can colorize based on a specific SQL Login or ALL Windows Logins.  So if you log in as sa, you can highlight it in red (for example), but if your windows login is IN the sysadmin role, it will be yellow unless you mark that windows logins are red.

    Downside to this is you need to set it up for each SQL instance and login individually.  And if you are using SQL Aliases or SQL browser for some of the times you connect and sometimes you include the instance and port, it becomes more of a pain as you need to set it up for EACH of these.  So you could have one for "admin" connecting as sa, "adminserver\admin" connecting as sa, "adminserver\admin, 4321" connecting as sa, plus 3 more for each sysadmin account you have on there.  Then repeat for each SQL instance you have... Management on that becomes a huge pain in the behind.  And to make it more fun - it is SSMS version specific.  SO you get it set up on SSMS 17, then install SSMS 18, you have to put it in again.  Thankfully you can export and import, but that is a pain to do if you have 5 different SSMS versions too.

    BUT if you do want to go this route - click on view->Registered Servers.  Then expand "Database Engine", right-click on "Local Server Groups", select "New Server Registration" and fill out the information you want in there.  To set the color, go to the connection properties tab and check off "use a custom color".  Now all new connections that match that registered server exactly (exact server name and login, does not affect current connections) will have the color you specified.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • Prompt does not colorize based on the login used for the instance. That's an interesting idea. I'll submit it.

  • Thinking more, I think colorizing based on login is likely not really what is useful. However, by role is interesting. It's usually the permission set we are about, so allowing colorization by role could be interesting.

    In general, our users are concerned about connecting to a prod server v a dev server. Your rights should be your rights on that server, regardless of login. Usually we are about being careful on those instances/databases in what we run, hence the choice to colorize based on an instance (or a particular instance/db)

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply