March 2017 update for SDU Tools–More free tools for SQL Server developers and DBAs

Hi Folks,

As promised, tonight we’re releasing the monthly update to SDU Tools, our free toolset for SQL Server developers and DBAs. A download link will be sent to all registered subscribers.

image

First, the new tools:

AnalyzeTableColumns – allows for quick profiling of a table. Shows the column metadata, and shows a sample of distinct values from each column. We suspect this will be the favorite this month. You can see it here: https://youtu.be/V-jCAT-TCXM

QuoteString – puts quotes around a string and doubles-up any embedded quotes. You can see it here: https://youtu.be/uIj-hTIhIZo

LeftPad and RightPad – pads a string to the left (or right) with a specified filler character. Useful for formatting strings or right-aligning numeric values. You can see them here: https://youtu.be/P-r1zmX1MpY

SeparateByCase – takes a pascal-cased or camel-cased string and separates out the words by inserting a space. You can see it here: https://youtu.be/kyr8C2hY5HY

StartOfFinancialYear and EndOfFinancialYear – calculates the start (or end) of the financial year for any given date, and allows you to specify the month when the financial year starts. You can see them here: https://youtu.be/wc8ZS_XPKZs

PrintMessage – annoyed at waiting for PRINT messages to come back in your stored procedures? Wait no more. You can see it here: https://youtu.be/Coabe1oY8Vg

And the new options:

We’ve added two other scripts to the download zip.

  • A script that can be used to completely remove the tools
  • A script that contains the sample code that we’ve used in the videos for this month

And the fixes:

We’ve also corrected a couple of issues that we had with collations (don’t you just love collations). And while we’re going to be super-careful about backward compatibility, we did rename one option. FindSubsetIndexes is now ListSubsetIndexes so it matches the other commands in that group. (The developer responsible has been dealt with Smile)

We hope you continue to use SDU Tools.

You can find out more about our free SDU Tools here:

http://sdutools.sqldownunder.com

 

SSMS: Removing all tabs in your query window with spaces

This is just a short post that I’ve been meaning to write for a while.

I know that there is an eternal tabs vs spaces debate that goes on in development teams. Currently I’m in the spaces team for SQL queries.

So, it’s a pain in the neck when I receive a script file from someone and it’s full of tabs. Even worse when there are a bunch of tabs at weird tab positions. And I start to edit it, and things jump around, and I think @#$@$!@#$@#$ tabs !

But nowadays, SSMS can help yet very few people seem to realize it.

If you hit Control-H to bring up the Quick Replace dialog (or do it manually when Control-H doesn’t work –> still investigating that), you can set an option to use Regular Expressions:

image

Click to turn that option on, it will have a background color (default is beige-ish). Enter \t for the from text, and 4 spaces (or whatever your favorite number is) for the “to” text and click the replace all option:

image

And you get to say “farewell you pesky tabs”.

I also often use this with \r etc. to replace multiple double-lines, etc. etc. (One day we might even get a macro recorder but this helps for many situations)

Hope that helps someone.