Author: way0utwest

  • T-SQL Tuesday #132 Pandemic Coping

    tsqltuesdayThis year, 2020, has been crazy. What started as a normal year for me, including a sabbatical, turned into a crazy, shutdown, lockdown, stuck at home pandemic around the world.

    My world changed a lot, as I cancelled a trip at the beginning of March, and all subsequent ones. Coaching volleyball stopped, and most events were cancelled, big changes for me.

    At the same time, my daughter came home from college and spent the rest of the semester with us and my oldest switched from teaching in person to being at home and finding a place he could virtually teach.

    This month, Taiob Ali asks us how we are dealing with these changes.

    Coping

    At first, I was coping fine with things fine. I live on a large ranch, my wife works from home, and I’ve been doing so for nearly 20 years. I have an office and am used to working here regularly. We are healthy and financially secure, and mostly it was a pain dealing with the changes in the world.

    As part of the Redgate Community Circleww, we started to think about how to help others, and came up with different ideas. One of mine was to publish some coping tips. At first, I was trying to help others, but over time, I found these to be invaluable to me.

    I get these from Action for Happiness for the most part, though I add some myself. I work through these in my life, often a few days in advance, and then write about them. I was thinking to stop these after June, but many people responded they liked them, and I’ve continued ever since then, which seems like a long time.

    I’ve also found these help me. During August, I struggled with the length of the changes, and the fact that looking forward another 6 months, I couldn’t see an end to the pandemic. The weight of the length of this weighs on me.

    Physical Health

    I’m in my 50s and exercise regularly, usually doing yoga or going to the gym 20+ days a month. My diet is OK, probably better than average America, but not great. Still, while my routine was interrupted in March, with less stuff than I’d like:

    2020-11-09 13_34_53-MapMyRun

    I got better in April and was in a good routine through June.

    2020-11-09 13_35_13-MapMyRun

    Mostly life was good until the end of October.

    I had a trip planned to visit family, but cancelled. My wife got sick, then I did, then my daughter. A week later one of my sons got sick. We had been diagnosed with COVID, and it was both scary and hard. The symptoms weren’t that bad, but all of my energy was sapped. I spent most of two weeks in bed or with very light chores around the house.

    2020-11-09 13_37_35-MapMyRun

    Since then, I feel better, but there are still some gaps in my health. I have no worry of dying, but I am worried about long term physical ability.

    Wear a mask, try not to get it, and if you don’t believe in masks or the disease, you’re a moron. Don’t leave me a comment on what you believe as a non-epidemiologist or non medical professional. Pardon my language, but fuck off.

    Mental Health

    I’ve struggled. Despite working at home for a couple decades, I’m used to changing my environment, going to see others, traveling, and more. Seeing my children depressed from school changes, not seeing the kids I coach, not getting to the gym, not going to restaurants and movies, it got to me.

    The longing for a change of environment, and not seeing the same four walls of my office weigh on me. The struggles I see on the news, especially from so many people losing jobs, businesses, and more are hard. I have a lot of empathy and realize I am incredibly blessed.

    I’ve made an effort to chat with others. To reach out at times, and ask for support from my wife and a few close friends.

    My mental health as suffered, even as I try to cope. I continue to work on this regularly, talking more, and trying to find the good things in my life as much as I can.

    Professional Growth

    I had hoped to do more learning, expecting that this pandemic would be less than six months. On one hand, I greatly underestimated the struggles of being at home all the time. On the other, I got some things done.

    I’ve had different goals this year, and I have spent some time learning more about Power BI, DAX, and visualization. I’ve read more business/non-fiction books this year than in the past. I’m making progress on goals. Not as much as I’d like, but some.

  • PowerShell Arrays and Hash Tables–#SQLNewblogger

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

    I was watching the GroupBy talk the other day and noticed that Cláudio Silva was using arrays, or what appeared to be arrays, in his talk. That was an interesting technique, one that I haven’t used very much.

    A day later, I ran into an explanation on dbatools.io, that showed this code:

    PS C:\> $columns = @{
    >> Text = 'FirstName'
    >> Number = 'PhoneNumber' 
    >> }

    That didn’t quite seem like what I wanted, so I decided to investigate more.

    I looked up PowerShell Arrays, and that wasn’t what I wanted. These are a list of values, as in

    $a = 1, 2,3

    Which gives me this:

    >>$a
     
    1 
    2 
    3

    Useful, but not for my purposes. I need to map things together, which means a hash table.

    Hash Tables

    It turns out I need a hash table. This is a key value pair that lets me pick a name and value and store them together. The way I construct these are with the @{} structure. Inside here, I set semi-colon separated pairs, with the name=value syntax.

    Here’s an example I used:

    $ColList = @{Date="EventDate"; Event="Event"}

    In here I map two keys (Date and Event) to two values (EventDate and Event). For the cmdlet I am using, this allows me to map these two columns together. When I need a value, I can use the $variable.key to get the value back.

    2020-10-28 13_37_45-C__Users_Steve

    I assume this is what the SqlBulkCopy cmdlet uses, which is what dbatools wraps. I ended up passing this $ColList hash table in for the –ColumnMap parameter.

    SQLNewBlogger

    A quick writeup that I used to solve a problem. I had some issues figuring this out, and some searching and experimenting got me a little better understanding of what was happening.

    After about 30 minutes of some work, I took 10 minutes to type this up and explain it to myself. A good example of what you could add to your blog, showing how you use this in your work.

  • Daily Coping 9 Nov 2020

    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.

    Today’s tip is to make a list of new things you want to do in the next month.

    Since this is 2020 and most things are strange and different, I’m going to pick the things that will be new in the “new normal” life I’ve been stuck with for months.

    Recordings – On my mind as I have 4 to do as I write this, not a small task.

    Get back in a workout routine – An illness derailed me, but I want to get back to this

    Build a wooden box – I’ve been wanting to do this with my daughter, so I need to get on this project.

    Re-engineer the door lift in the riding arena – A motor broke, or rather, got used incorrectly and I need to replace it. While doing it, I need to improve some things.

  • Strange T-SQL Operator Syntax

    I can’t remember where I saw this, but it made an interesting Question of the Day:

    select *

    from Sales

    where Profit !< 10000;

    I had never seen anything like this, in all my years of working in C, C++, Java, Lisp, APL, Pascal, Fortran, VB, C#, SQL, and more. However, there are apparently a few operators that I’ve never used:

    • !<
    • !>

    These are the not less than and not greater than.

    Weird, though I guess this makes sense. Personally, I think restructuring as greater than or equal to instead of not less than makes perfect sense.