r/SQLServer • • Jan 30 '23

Tips for SQL Management Studio

After years of using it I realized I can color code query windows, so 'red' for production, 'green' for dev servers. Any other tips people have?

34 Upvotes

63 comments sorted by

17

u/planetmatt Jan 30 '23

Use Registered Servers to deploy the same scripts to different groups of servers, or to quickly query data across multiple servers.

4

u/kohkypc Jan 30 '23

Wow. I just tried this with @@version across multiple services, and found an issue. Thank you very much!!

7

u/sholder89 Jan 30 '23

I've been a working with databases for 10 years I probably learned this one about 4 years ago. I can't believe how much time this has saved me, even just running diagnostic scripts against multiple servers etc.

1

u/kohkypc Jan 30 '23

Cool. I will check this out. Thanks friend!

3

u/OhIT_MyWorkAccount Jan 30 '23

Using a CMS server tied into Registered Servers is such a game changer once you start. Allows all DBA's to see/query the environment at a quick one-stop location, can arrange servers however you'd like, can quickly run queries to gather information/update environmental settings across the board/etc.

2

u/planetmatt Jan 30 '23

Yep, and you can have groups for instance to configure instance level stuff like DBMail, and groups of HA Listeners, to target DB level stuff. Also groups for environment (test, uat, live), and version (2008,2012,2016,2019) . Also allows whole teams to work from a central master list of servers and groups.

2

u/OhIT_MyWorkAccount Jan 30 '23

100% agreed. I have dozens of AG's and standalone servers registered in my CMS and have it set up so the same instances are grouped by environment, by datacenter, by SQL version, by node intent (primary/secondary-sync-auto-failover/secondary-async-manual-failover/etc), by which WSFC cluster they fall under, etc.

13

u/alinroc 4 Jan 30 '23

Shortcuts From an Impatient DBA has lots of ways to speed up your work in SSMS

1

u/kohkypc Feb 03 '23

Very helpful. Thank you!

4

u/sholder89 Jan 30 '23

Just watched this whole video, learned at least a couple new tricks and was reminded of some old ones. Thanks for sharing!

5

u/Gnaskefar Jan 30 '23

If you need to edit some rows in the GUI, when you have clicked the 'edit top 200 rows' you can press ctrl + 3, and then you can edit the query that shows you the 200 rows.

I know, one is not supposed to edit rows if not in a script yada-yada, but when live debugging, finding stuff, changing a WHERE clause, and see the area of certain values etc, it's very handy.

You can also change thedefault amount of rows, so it not 200 in the interface. Can't remember where though, but you can. I promise.

2

u/kohkypc Feb 03 '23

I did not know that. That's cool. Thank you!!!

4

u/[deleted] Jan 30 '23

right click the scroll bar in the query window and you can change it to map mode. It’s much like the code preview scroll bar is vs code. great for long queries.

1

u/kohkypc Feb 03 '23

That's so cool. I never knew about that. Thanks!!!

3

u/coldflame563 Jan 30 '23

Use SSMS boost. Best addon ever!

1

u/kohkypc Feb 03 '23

Thanks. It didn't seem to load on SSMS 19. Do you know if there will be an update?

1

u/Simonopio Jan 31 '23

There hasn’t been an update since COVID, wondering what happened.

1

u/namtab00 Jan 31 '23 edited Feb 01 '23

yeah, I'm really worried it's dead...

I can't work without its formatting functionality...

haven't yet tried to install it on SSMS 19, has anyone?

2

u/Leroy_UK Jan 30 '23

In Options > Environment > Fonts and Colors you can change the colour for Operators, Sprocs, Strings, etc. look for Display Items starting with SQL.

Not as nice as some for the themes in ADS but something.

1

u/kohkypc Jan 30 '23

I'll investigate. Thank you for your reply!

2

u/mafaso Jan 30 '23

Can you tell us how to do that?

2

u/taspeotis Jan 31 '23

If you spend a lot of your day inside of SSMS you should evaluate DataGrip. I say this as someone who used SSMS a lot and had a lot of muscle memory for its keyboard shortcuts. DataGrip has a learning curve but it was worth it for me in the end.

SSMS displays execution plans better than DataGrip, but if I am tuning queries I usually drop them into Plan Explorer.

2

u/kohkypc Feb 03 '23

Thanks for the heads up!

2

u/nemec Jan 31 '23

I don't think I have the code anymore, but I once wrote an extension that sent a Windows notification if a query finished while SSMS was in the background. Great for running a long query then fucking off to Reddit for a bit while you wait for it to finish.

1

u/kohkypc Feb 03 '23

I love this idea. Was it easy to write an extension?

2

u/nemec Feb 03 '23

It was kind of difficult, unfortunately. I used an OSS library that created the notification, but figuring out when to send it took a lot of digging around in decompiled SSMS DLLs. Actually, in the end I may have settled on a timer that ran every few seconds and checked the tab titles for when one stopped executing. That is a much easier solution than deeply hooking into SSMS.

2

u/Traust Jan 31 '23

Holding the ALT key and using the cursors/mouse you can select multiple lines and characters at the same time in a block. Great when you need to comment out a heap of lines at once or add/remove text.

Works in a number of other applications too like notepad++ but each program has it's own quirks, like one application I use I can push the end key to go the end of all the lines selected or home for the start but does not allow using the arrow keys to select things.

1

u/kohkypc Feb 03 '23

Wow. That is really cool. I can see how that would be really useful. Thanks so much!

2

u/rottenrealm Jan 30 '23

4

u/sholder89 Jan 30 '23

This looks cool, anyone know how it compares to Red Gate SQL Prompt?

1

u/kohkypc Jan 30 '23

Interesting. Sounds like you feel it is worth the price?

2

u/rottenrealm Jan 30 '23 edited Jan 30 '23

The free edition is full of cool features , including coloring, but if you are a full scale db programmer you gonna buy it after trial for sure. I'm ready to pay just for automated aliasing.

1

u/kohkypc Feb 03 '23

Thank you!

2

u/sea_5455 Jan 30 '23

If you're trying to connect to an instance with a non- standard port number, the port number can be specified by number after a comma such as:

Hostname,12345

In the connect to server window.

2

u/kohkypc Feb 03 '23

Good to know. Thank you!

4

u/[deleted] Jan 30 '23

Are there any ways to apply Dark Mode?(

9

u/guerreroyaqui Jan 30 '23

sqlshades.com

1

u/namtab00 Jan 31 '23 edited Jan 31 '23

doesn't work for Object Explorer Detaila, but at least works for Object Explorer

3

u/poem_in_your_mind Feb 01 '23

Will be fixed in the next release

1

u/namtab00 Feb 02 '23

hey, just a quick huge thank you for sqlshades and for making it available for free..

...if I may, if you don't plan on monetizing it, please open source it.

I'd hate it if it ended up like SSMSBoost...

1

u/namtab00 Feb 20 '23

any ETA on that next release?

1

u/[deleted] Feb 01 '23

It is part of the SSMS19 release.

0

u/alinroc 4 Jan 30 '23

There is no supported Dark Mode for SSMS. And it's not planned. If you need Dark Mode, use ADS.

3

u/ihaxr 2 Jan 30 '23

Except they had it working a few years back then noped out of it. You can still enable it via an XML hack but then you can't see some menus.

I only use SSMS when I have to, otherwise Azure data studio and PowerShell

1

u/Black_Magic100 Jan 31 '23

Ctrl k + Ctrl c to switch server connection of an open query tab

Ctrl + 3 to run a modified version of sp_whoiscactive

I use that one probably 50 times a day.

1

u/kohkypc Feb 03 '23

Thanks!

1

u/sholder89 Feb 01 '23

Ctrl k + c will comment out a line, switching a connection would be Alt + qch

Ctrl + 3 running sp_whoisactive is useful but you have to set this up yourself in Options > Environment > Keyboard > Query Shortcuts, this is not something thats default, though Ctrl + 1 should be set up to run sp_who by default.

2

u/Black_Magic100 Feb 01 '23

Right. I switched the keybind for the connection. Also, I don't really like sp_who so binding whoisactive was worth it to me.

1

u/sholder89 Feb 01 '23

Absolutely agree, sp_whoisactive is awesome. In fact I just made the same binding on my setup based on your comment so thank you for that idea! Just wanted anyone who reads it to know how to set it up! :)

-6

u/jpro1001 Jan 30 '23

1 tip: Use Azure Data Studio

1

u/kohkypc Feb 03 '23

This is a reminder to download it and start to use it just to get used to it. Thank you!

5

u/Contradicting_Pete Jan 30 '23

Why?

6

u/Odd-Resort-3804 Jan 30 '23

I also would like to know. Used for a week before I went back to ssms. I have a colleague that swears by data studio though.

6

u/ihaxr 2 Jan 30 '23

You can open Azure data studio, run your query, then close azure data studio while the SSMS splash screen is still up taunting you... There's some stuff that you have to use SSMS for, but for everything else I'll use ADS

0

u/jpro1001 Jan 30 '23

More features. Sorry if I was being facetious. Trying to be funny.

11

u/digitalnoise Jan 30 '23

More features. Sorry if I was being facetious. Trying to be funny.

Not if you're a DBA.

1

u/jpro1001 Jan 30 '23

Ya some of the settings pages need to be installed as extensions...

3

u/totaIIybored Jan 30 '23

Renders JSON really well

0

u/[deleted] Jan 30 '23

[deleted]

1

u/kohkypc Feb 03 '23

Good suggestions. Thank you!