Senior Consultant at SQL Solutions Group. The views expressed here are my own and not of my employer. He/him

Republic of the Philippines
Joined July 2015
Daniel Maenle retweeted
This man volunteered to tell a joke and absolutely killed it
97
1,608
147
11,488
973,026
RETWEET if you stand with Jack Smith against Trump!
469
4,195
63
10,184
116,082
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…
5,620
9,744
578
60,008
11,969,292
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.
2
8
15
1,403
📬 The How To Write SQL Server Queries Correctly Cheat Sheet: Select List Subqueries: ift.tt/PHI6f7F 📬
3
6
822
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.
802
22,982
2,308
138,513
6,034,536
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?
251
355
22
1,664
66,755
911
3,491
92
23,404
541,614
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…
30
309
10
2,298
268,209
My company is hiring for a Senior Database Administrator. Apply here and or hit me up for more information. careers.abarcahealth.com/det… #sqljobs
2
8
6
1,536
Pretty good point.
420
4,412
201
16,177
365,855
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…
21
231
15
1,403
87,792
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
6
18
4
42
8,360
The kindest person in the room is often the smartest. @GovPritzker ht @profgalloway.
42
446
86
1,349
178,911
New blog post: SQL Server Diagnostic Information Queries for September 2023 glennsqlperformance.com/2023… #SQLServer #AzureSQL
3
11
880
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...
74
845
139
8,988
859,288
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
20
118
8
405
42,693