Daniel Maenle retweeted
Hello, Detroit! With only two weeks left until Election Day, we’ve got to do all we can to elect Kamala Harris and Tim Walz. Tune in to hear from me and Eminem: xitter.cf/i/broadcasts/1LyGBgjBj…
Daniel Maenle retweeted
To explain this a bit more to those who have asked:
The documentation for CAST & CONVERT says:
Starting with SQL Server 2012 (11.x), when using supplementary character (SC) collations, a CAST operation from nchar or nvarchar to an nchar or nvarchar type of smaller length won't truncate inside a surrogate pair. Instead, the operation truncates before the supplementary character.
Under an SC collation, each character has a variable byte length. For example, N'X' takes 2 bytes, while N'😎' uses 4 bytes.
The string N'X😎' (both characters together) requires 2 + 4 = 6 bytes of storage, corresponding to nvarchar(3). The number in brackets is the number of byte-pairs, not the number of characters. Three byte-pairs = 2 * 3 = 6 bytes. Yes, it's confusing but that's how it is.
-- Returns 6 (bytes) and 2 (characters)
DECLARE @y nvarchar(3) = N'X😎';
SELECT DATALENGTH(@y), LEN(@y);
If we convert the string to a smaller type, truncation occurs:
-- Returns "X", 2 (bytes), and 1 (character)
DECLARE @y nvarchar(3) = N'X😎';
SELECT
CONVERT(nvarchar(2), @y),
DATALENGTH(CONVERT(nvarchar(2), @y)),
LEN(CONVERT(nvarchar(2), @y));
This is the correct behaviour. Truncation stores as many whole characters from the string as will fit in the destination type. nvarchar(2) offers 2 * 2 = 4 bytes, which is only enough to store the first character, N'X'. There is not enough space left to store the 4 bytes of N'😎'.
The bug occurs when the source is a LOB type, the destination is nvarchar (or nchar), truncation is needed, and the truncation point occurs within a (variable length) character.
Using the same example with a LOB source:
-- Returns "X�", 4 (bytes), and 2 (characters)
DECLARE @y nvarchar(max) = N'X😎';
SELECT
CONVERT(nvarchar(2), @y),
DATALENGTH(CONVERT(nvarchar(2), @y)),
LEN(CONVERT(nvarchar(2), @y));
The funny-looking second character is the first 2 bytes of N'😎' (which requires 4 bytes). Conversion has split this character in half! This is the bug.
an interesting bug report from @SQL_Kiwi - feedback.azure.com/d365commu…
Daniel Maenle retweeted
📬 The How To Write SQL Server Queries Correctly Cheat Sheet: Select List Subqueries: ift.tt/PHI6f7F 📬
Daniel Maenle retweeted
Just received word from King Kai. Legendary manga creator and the father of Dragon Ball, Akira Toriyama, has passed through the Other World Check-In Station.
Daniel Maenle retweeted
I like that Biden is going to propose to build a port in Gaza to get them humanitarian supplies in tonight's #SOTU2024. But why do we have to build a port to get around our own ally? And why are we giving them billions when they refuse to listen to us at every turn?
Daniel Maenle retweeted
Oh my god…
Today is the 11-year mark of Sandy Hook and still nothing has changed. We just released this video @DemocracyMoms with our partners called Thoughts & Prayers. We hope you follow us there and donate to the cause to help us get this on the air. #gunreform secure.actblue.com/donate/m4…
Daniel Maenle retweeted
My company is hiring for a Senior Database Administrator. Apply here and or hit me up for more information.
careers.abarcahealth.com/det…
#sqljobs
Daniel Maenle retweeted
The best #SQLServer training on the internet, now with a new home (and 75% off): training.erikdarlingdata.com…
Daniel Maenle retweeted
Just dropped my new YouTube video monologue: How Unions CRUSH Capitalists.
This one is really important to me, in many ways a culmination of the last year I've spent thinking about unionism, what it means, and what it can accomplish. Hope you enjoy.
youtube.com/watch?v=mcgC-kuP…
Daniel Maenle retweeted
Help me make this go viral! Do you know about SQuizL, essentially Wordle for #SQL. It's from #Oracle, but it's fun for the entire #SQLfamily, whatever your #database. I hope you'll check it out and let your followers know about it. bit.ly/SQuizL-game
Daniel Maenle retweeted
The kindest person in the room is often the smartest.
@GovPritzker ht @profgalloway.
Daniel Maenle retweeted
New blog post: SQL Server Diagnostic Information Queries for September 2023
glennsqlperformance.com/2023…
#SQLServer #AzureSQL
Daniel Maenle retweeted
In every majority-Christian nation, the systems are set up to ensure those with the most resources receive the most care and support. We're so accustomed to this that we may even consider it "natural." But this is not how Christian sacred texts want social orders designed...
Daniel Maenle retweeted
More of this, please. comicsands.com/sub-radio-des…
Daniel Maenle retweeted
They underestimated the power of young people last time. They will be stupid to ignore Gen Z voters again. A new generation is rising.
HT @ElevenFilms
#GenerationDemocracy



























