Category: Blog

  • A Little Current Date Arithmetic in Powershell–#SQLNewBlogger

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    I saw a fun post on Twitter recently asking days until retirement. I wrote this code:

    DECLARE @YearsToRetire INT = 11;
    SELECT DATEDIFF (DAY, GETDATE (), (DATEADD (YEAR, @YearsToRetire, GETDATE ())));

    I thought that wasn’t bad, but then I wondered, how would I do this in PowerShell? I knew there had to be a way, so I googled and ran into this article. That showed me Get-Date and the AddYears() method. So I tried this:

    2022-01-05 10_26_03-C__Users_Steve

    That didn’t work well. I ended up storing the date in a variable and then things worked. However, I was bothered. I can pipe and combine things, why didn’t this work?

    Then I thought about something. I ought to enclose the Get-Date inside something. I tried parens, like this:

    (Get-Date).AddYears(11)

    That worked great. As I get more familiar with PoSh, I can figure more things out myself, and quicker.

    2022-01-05 10_28_06-C__Users_Steve

    SQLNewBlogger

    Once I figured out the way to do this, I spent about 5 minutes on this post. Actually 6 minutes with this part added.

    I took something I figure out and wrote this up quickly. I even added a great line at the end, that I figured it out and my work with the language is paying dividends.

    A great little type of post that would highlight your blog.

  • Daily Coping 12 Jan 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 write a short list of 3 things you feel grateful for and why.

    My list:

    • Health
    • Finances
    • Kids

    Not the top list, and certainly I am grateful for my wife and my own kids, but these are additional items.

    Health

    I’ve been relatively healthy for most of my life. While I have bad knees and ankles, some joint issues, most of these are minor and impede my ability to be athletic, but don’t prevent it. I’ve rarely been sick. I’ve had COVID and I had the flu one other time. I get colds every 2-3 years, but for the most part, I don’t have any chronic issues.

    I got some worrisome numbers at my last checkup. Nothing too bad, but for someone that mostly gets a clean bill of health, I need to change a few things as I age. I’m “pre” a few things, so I’m working to get better, but that has helped me appreciate how blessed I am, even as I need to pay more attention.

    Finances

    I’ve had a good career, with jobs that paid well. Nothing amazing, but I have been well compensated for most of the last 30 years. I also built and sold a business, which didn’t let me retire, but it made life comfortable for my wife and me. My wife also had a great job and provided more support for the family than I did for a long time.

    We’ve invested in real estate, had good success, saved some money from corporate 401k plans, and we are in a great position. While we aren’t able to retire in our 50s, and college for kids is a bit of a strain, we are in a better position than most people in the world, and I’m grateful for the security and peace of mind that brings.

    Kids

    I have three adult kids, and I enjoyed watching them grow up. I enjoyed being a part of their activities, their successes, and their struggles. I am very proud of where they are in the world.

    However, I miss the time I used to get with kids, watching them learn and grow. Fortunately, I have become a decent volleyball coach and can spend my hobby time there. My wife and I have spent the last 3 years together running teams of kids during the winter and spring, competing at a fairly high level.

    As tired as I can get and as stressful as some events can be, I love spending 6 months with a group of kids, watching them learn, grow, struggle, and succeed. I take a lot of pleasure in seeing them later as they continue to grow and develop.

    I’m grateful that these kids are a part of my life.

  • Daily Coping 11 Jan 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 make time to do something kind for yourself today.

    I booked a massage. I don’t do this very often, but I took a break from life and booked a hot stone massage, always a relaxing treat in the winter.

    I often tend to think about others before myself, so this was a good reminder to take care of myself.

  • T-SQL Tuesday #146–Changing Preconceptions

    tsqltuesdayIt’s the start of a new year, and the first T-SQL Tuesday is from Andy Yun. I’ve known Andy a long time and this is his third time hosting with a creative prompt for us all to consider.

    I really like this one as it could be taken as a technical or a non-technical prompt. What did you think was one way and you learned it was another way. Always good to stop and double check that your view is actually representing what you think.

    We all do this in our views of life as well as work, and it can be hard to change what or how we think. This is especially true for many of my customers, as I find them wanting to adopt DevOps, but not really wanting to change.

    I’ll tackle this one in a couple ways, one technical and one non-technical.

    Separate Accounts for Each Instance

    For a long time, I always used separate domain accounts for each SQL Server service. Even in a large environment, with hundreds of instances, I did the work (or have junior DBAs do it) to ensure that each service was account separated. This was important because I’ve had change passwords and other issues break services in the past. None of the incidents seemed worth saving a bit of time to set up separate accounts.

    Over time, and as SQL Server evolved, Group Managed Service Accounts came into being. I resisted using these at first, but over time I’ve realized that these are valuable and provide security as well as ease of administration. If I went back to managing servers, even single ones, I’d likely look to ensure that gMSA was the standard.

    Take Feedback as An Opportunity

    I’ve struggled with having someone criticize me for my work. I’ve even struggled when they suggest something else, bristling at the idea that I wasn’t doing something well. Often I was successful and doing something well, but there might be a better way.

    Across time, and age, I’ve learned to appreciate other points of view and not become defensive to feedback. Instead, I’ve started to look at other views as a chance to learn or grow, or even just try something. I can still reject the advice or suggestion, but I ought to consider it.

    I’ve started to adopt the “strong opinions, loosely held” philosophy at work.

    Note, I’m trying to do this in my personal life, but I still very much suck at this.