The Bit Bucket

SDU Tools: Analyze SQL Server Table Columns

I spend a lot of time reviewing other people’s databases. Apart from looking at table designs, data types, keys, etc. I’m often interested in what the typical data in the table looks like.

In our free SDU Tools for developers and DBAs, we have added a special tool called AnalyzeTableColumns that makes this type of review easy. You point it at database, schema, and table, and it tells you about the table.

2018-07-11

Opinion: Singular vs Plural Table Names in SQL Server

There is a near-religious debate in the development and DBA communities about singular and plural table names. It’s pointless rehashing all the arguments but I want to spell out what I do, and why.

What’s driving this post is that I had a developer tell me that I was doing it inconsistently because even though I generally use plural names, that he found a table where I used a singular name. He thought this was inconsistent. It’s not, and this is why.

2018-07-10

SQL: Why can't I see my files in SSMS when I want to restore?

I had a curious discussion on a mailing list the other day where the questioner was complaining that SQL Server Management Studio (SSMS) wasn’t working properly. He wanted to restore a backup, and his folders did not appear in the folder list to choose from. He could see them in Windows File Explorer but couldn’t see them when trying to restore a backup.

What he wasn’t understanding is that when you use SSMS to perform a restore, what you are doing is sending a command to SQL Server to tell it to do a restore. SQL Server is going to open the file and get the contents out of it, not via your local copy of SSMS.

2018-07-09

Book Review: Astrophysics for People in a Hurry - Neil DeGrasse Tyson

I have to admit to being a bit of a fan of Neil DeGrasse Tyson, so I was really looking forward to reading or listening (via Audible) to his book Astrophysics for People in  Hurry.

It’s always a bit of a tall order to try to cover something like Astrophysics in a short book. The title reminded of silly book titles like “Applied Multivariate Analysis and Calculus for non-Mathematicians”.

But I loved this book.

2018-07-06

SDU Tools: Converting between Base64 and Varbinary in T-SQL

In our free SDU Tools for developers and DBAs, we have added many tools that help to convert data between different types and formats when working with T-SQL.

In some recent consulting work, I needed to convert data from BizTalk messages into other formats. To help make this easy, I added a function that converts from the Base64 (used by Biztalk messages and other applications) into varbinary.

Not surprisingly, we called it Base64ToVarbinary. And for completeness, we also added the reverse function: VarbinaryToBase64.

2018-07-05

Shortcut: Fixing or improving SQL Server Books Online

I mentioned in an earlier post that I think the online version of Books Online (BOL) is now superior to the version that you can install locally.

I particularly like the way that the online books are now cross-version ie: each page covers all supported versions, instead of having a separate page for each version.

But one of the really big bonuses is that you now have the opportunity to change the documentation if you think it’s incorrect or you think it could be improved. Microsoft have placed all the documentation in a Git repository and you can change it. Doing so is easier than you might expect.

2018-07-05

SQL: Finding rows that have changed in T-SQL - CHECKSUM, BINARY_CHECKSUM, HASHBYTES

If you have data in a SQL Server table and you want to know if any of the values in a row have changed, the best way to do that is by using the rowversion data type. (Note: this used to be called the timestamp data type in a rather unfortunate naming choice). I’ll talk more about it in another post.

But today I wanted to discuss the another issue. If I have an incoming row of data (let’s say @Parameter1, @Parameter2, @Parameter3, @Parameter4) and I want to know if the incoming values match the ones already in the table and update the table only if they are different, what’s the best way to do that/

2018-07-02

Book Review: Essentialism - Greg McKeown

Another book that I’ve been listing to lately on Audible is Greg McKeown’s Essentialism: The Disciplined Pursuit of Less.

This was a very timely book for me. I find it very easy to get endlessly bogged down in minutia, rather than just always focusing on the big picture of what I’m doing. It’s really easy to do that if you have a great desire to get things perfect or close to perfect. But that’s not what you should be aiming for.

2018-06-29

Shortcut: The magical F1 key - help on syntax and metadata

I used to always recommend that people install Books Online (BOL) on their systems. It’s ironic that it was called “Online”, given we’re really talking about “Offline” nowadays, but back when we first were talking about it, we were comparing it to a physical book, not to a live reference on the Internet.

Nowadays though, I find that the version online is so far superior to the one that you can install locally, that I think it’s better to just use the online version. I particularly like the way that the online books are now cross-version ie: each page covers all supported versions, instead of having a separate page for each version.

2018-06-28

SDU Tools: Create a linked server to Azure SQL Database from SQL Server

When I need to move small amounts of data between an on-premises SQL Server system and an Azure SQL Database, or run queries that involve both systems, the easiest option at present is to create a linked server to Azure SQL Database.

And the easiest way to do that (or if you can’t remember the commands) is with one of our free SDU Tools for developers and DBAs, called CreateLinkedServerToAzureSQLDatabase. You can read it to check out the code, or use it like this:

2018-06-27