Category: Blog

  • T-SQL Tuesday #143 – Short Code

    T-SQL-Tuesday-LogoI’m late, but I wanted to get this out. I started the post, then got distracted with travel to Europe late last week.

    In any case, this month the host for T-SQL Tuesday is John McCormack, with his invite to write about short code examples. It’s a good technical invite, and one that immediately got me thinking about things I do often.

    If you haven’t ever tried a T-SQL Tuesday, set up a blog and put out a post on the topic, this week or whenever you read this.

    Snippets

    I work for Redgate Software, though I’d likely be using SQL Prompt no matter what. I was never thrilled with native intellisense, but SQL Prompt has been great. One of the things I like most about Prompt are the snippets, which let me insert code with a few keystrokes.

    Here’s a quick example. If I type “” in SSMS, I see this:

    2021-10-13 10_52_32-CandidateList

    Prompt detects this as a snippet first, then has other matches. I can hit Tab, and I’ll get this:

    2021-10-13 10_52_46-CandidateList

    I get a quick “top 10” from a table. Often I use SELET * for a quick look at the shape of data.

    However, I can add custom snippets, and one I use often is this:

    WITH myTally(n)
    AS
    (SELECT n = ROW_NUMBER() OVER (ORDER BY (SELECT null))
      FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) a(n)
       CROSS JOIN (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) b(n)
    )
    SELECT *
    FROM myTally

    This is my “tt” snippet, so I can type “tt<Tab> and get this code for a tally table. This s handy in many string manipulation and problem solving situations.

    If I need more than 100 rows, I can easily copy the cross join line, add a new alias, and I have 1000 rows with this:

    WITH myTally(n)
    AS
    (SELECT n = ROW_NUMBER() OVER (ORDER BY (SELECT null))
      FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) a(n)
       CROSS JOIN (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) b(n)
       CROSS JOIN (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) c(n)
    )
    SELECT *
    FROM myTally

    Short, but effective code.

  • Redgate’s Pre-con at the 2021 PASS Data Community Summit

    I was fortunate to present a pre-con at the PASS Summit alongside Kendra Little in 2019. That was the last in person event, and I really enjoyed the session. I”m not presenting a pre-con this year, but I am part of the PASS Data Community Summit keynote and also presenting a session in the Database DevOps learning pathway “A version Control primer for Databases”.

    Redgate is sponsoring a pre-con with Grant Fritchey, who blogged about the Redgate pre-con, DevOps for the DBA This takes place online on Tuesday November 9. The pre-con is just $200, which is much reduced from the usual fee, and what’s even better is that all of the proceeds will be donated to Black Girls Code.

    It’s a chance to learn about introducing automation into your database development process and aligning with the DevOps techniques that your applications developers use. You also can support a great charity that helps kids enter our field.

    Register today and I’ll see you online next month at the Data Community Summit.

  • Daily Coping 12 Oct 2021

    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 find something to be optimistic about, even if life is hard.

    I find that life is pretty easy for me. Being in Colorado, we’ve managed the pandemic well, many things have opened, and I live out in the country, so I am not often around groups of people.

    I’ve found that the things that are important in my life are starting to move forward a bit. First, I’m back to traveling and speaking. Today I deliver a live talk in Belgium. That’s been a bit part of the last ten years for me, and I’m glad to be getting back to this.

    Second, it looks like ski season and volleyball competition will be relatively normal right now. The scheduling and format is what I expect, and that has me excited about the next six months. Even if we have to wear masks as coaches, I’m fine with that. Let’s live some life.

    Third, my family is healthy, happy, and growing in their lives, each in their own way.

  • Daily Coping 11 Oct 2021

    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 write down three things you can look forward to in the next month.

    I’m writing this before I travel, and today I’m in Belgium at the Data Minds Connect conference. The first live conference in nearly two years for me.

    I’m looking forward to a lot of things coming up. The first one is SQL Saturday Orlando 2021. This is the first live SQL Saturday taking place since the pandemic hit. While it might be a little early, there are other events starting to move forward and I’m glad this one is taking place. I’ll be traveling back to Orlando at the end of the month.

    Second, I am really looking forward to volleyball starting again. Last year was an incredibly long season, about 11 months for me. I was worn out in June when we finished, and I needed a break. However, after a few months off, I’ve started to watch some of my team competing in high school, and I’m ready to start coaching.

    Third, I am looking forward to cooler weather. It’s been a long, hot, dry summer in Colorado, and I’m ready to put on some jackets and enjoy fall. I’d love snow, and I’ll likely still wear short pants as often as I can, but I like the changing weather.