Category: Blog

  • Daily Coping 22 Jun 2022

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

    Today’s tip is to take time to notice things you find beautiful.

    This probably doesn’t look like much:

    20220618_132029

    It’s a new manure spreader. It’s a work of engineering and art, at least compared to the old one. We’ve had the same one for 15 years, and it was small, the bottom rusting out, the wire cables that operate it were frayed a bit and I’ve had no shortage of scratches and cuts while using it.

    I didn’t use it often, but each time I did, I wished we had a new one. Or that I’d have time to take things apart and replace them. I never did, but it eventually rusted the bottom and we bought a new one.

    Seeing this in action is beautiful, and while I don’t relish the chore of spreading manure, I am think it will be more enjoyable when I do need to use this device.

  • Daily Coping 21 June 2022

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

    Today’s tip is to speak to others in a warm and friendly way.

    I’ve been traveling a lot lately. This means I’m running into lots of people I’ve never met, and a few I have. Last week I started this tip while at VSLive in Austin.

    I do remember that many people can be introverted and shy, and others are ignored. I usually try to be polite and welcoming to people, even when I’m introverted and tired. Specifically, I made it a point to be polite (please, thank you, excuse) me to staffers at the hotel. I’ve done those jobs, and I appreciate how they can be stressful.

    I also made an effort across just two days to greet, smile, and be polite to other attendees. Hopefully setting a good example of what I like to see from others at events, where they have opportunities to network.

  • Daily Coping 20 Jun 2022

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

    Today’s tip is to send a positive message to a friend who needs encouragement.

    I get these sometimes from friends, and I love them. I also try to remember to do this.

    I had a friend that had to go through a tough time with a family member being sick recently. Everything is fine, but I know the aftermath of this and trying to get back to normal is hard. I made it a point to reach out every day or two for a few days to check on them and just offer encouragement.

    You could do that randomly as well, even if someone isn’t needing encouragement. Just let them know you are thinking of them.

  • New in SQL Server 2022 – Generate_Series

    One of the new language features added in SQL Server 2022 is the GENERATE_SERIES function. This allows you to generate a

    SELECT * FROM GENERATE_SERIES(start=1, stop=7)

    This gives me a simple sequence of numbers in a result set, with the column header, value.

    2022-03-31 14_57_20-SQLQuery3.sql - ., 51433.sandbox (sa (80))_ - Microsoft SQL Server Management St

    Let’s take this code from Dwain Camps article, Tally Tables in T-SQL:

    DECLARE @S VARCHAR(8000) = 'Aarrrgggh!';
    SELECT value, s
    FROM
    (
         -- Always choose the first element
         SELECT value=1, s=LEFT(@S, 1) UNION ALL
         -- Include each successive next element as long as it’s different than the prior
         SELECT value, CASE
             WHEN SUBSTRING(@S, value-1, 1) <> SUBSTRING(@S, value, 1)
             THEN SUBSTRING(@S, value, 1)
             -- Repeated characters are assigned NULL by the CASE
             END
         FROM GENERATE_SERIES(start=1, stop=100)
         WHERE value BETWEEN 2 AND LEN(@S)
    ) a
    -- Now we filter out the repeated elements
    WHERE s IS NOT NULL;

    Now the original code has a CTE that generates the series, or tally table. I’ve replaced that with GENERATE_SERIES. The code works as expected, which in this case is to remove repeating characters.

    2022-03-31 14_58_21-SQLQuery3.sql - ., 51433.sandbox (sa (80))_ - Microsoft SQL Server Management St

    SQL Server 2022 is now out in preview and I’d urge you to give it a try. This is a neat new feature, and it does provide more standard code than the variety of ways I see people building tally tables.

    I haven’t tested performance, but I am hoping it does as well as cross joining system tables or using a CTE.