Sometimes you find yourself stuck in a rut and you never even know that there is a rut. That’s where I found myself today my friends! For years – and I do mean years – when I’ve been asked for the first 10 rows from a query, I would do the following: SELECT TOP 10…… Continue reading TOP of the Mornin’ to You!
Month: September 2021
More Fun with Smushing Data Together
Last week, we learned all about the old-style string concatenation and the new-ish, hip CONCAT function. This week, it’s time to talk about the CONCATs lesser talked about, but equally helpful cousin – CONCAT_WS. With CONCAT, we formatted the person’s name in a LastName, FirstName format using the following query. SELECT CONCAT(TRIM(LastName), ‘, ‘, TRIM(FirstName))…… Continue reading More Fun with Smushing Data Together
Sometimes You Need to Push Strings Together
Every now and again, you’re probably going to have to slap a few strings together in your fun with SQL. A long time ago (20 years ago), in SQL Server world, there was only one way to do it – and sadly, you’ll probably see many developers still doing it this way. SELECT LastName +…… Continue reading Sometimes You Need to Push Strings Together
Time to give the data a TRIM()
For years, when it came to getting rid of the spaces at the beginning/end of a string, you were stuck with using the functions LTRIM and RTRIM – meaning left trim and right trim respectively. For many versions of SQL Server – and probably quite often even in code written today – you will see…… Continue reading Time to give the data a TRIM()