A small slice of pie

Think twice about storing JSON in your SQL Server database

During routine maintenance on a customer’s production server, I discovered that they have one table consuming 40% of the storage in their database. That table contains just under 10 million rows, which isn’t that remarkable; another table in the same database has almost 500 million rows. The remarkable thing — because you read the subject
-> Continue reading Think twice about storing JSON in your SQL Server database

Why is a value in DATETIME2 8 bytes, but in BINARY it is 9 bytes?

In the #sqlhelp Slack channel on the SQL Server Community Slack workspace last month, Jemma Hooper asked: When trying to CAST or CONVERT a datetime2 value to binary(8), I’m getting a “binary or text data would be truncated” error. This seems really weird in context with the fact that SELECT DATALENGTH() on a DATETIME2 value
-> Continue reading Why is a value in DATETIME2 8 bytes, but in BINARY it is 9 bytes?