Category: Blog

  • 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.

  • What’s Your Vision for PASS?

    The PASS election slate was released for 2020. The candidates and their statements are::

    1. Hamish Watson (@thehybriddba)
    2. Joey D’Antoni (@jdanton) – Community Matters–Why I’m Running for the PASS Board of Directors
    3. Jose Rivera –  (@SQLConqueror) –
    4. Lori Edwards (@loriedwards)-
    5. Matt Gordon (@sqlatspeed) – Why I Am Running for PASS Board
    6. Robert Fonseca (@roberto_mct) –
    7. Steph Locke (@TheStephLocke) – I’m Running for the PASS Board

    Not everyone has a statement, though you can read their bios and applications on the PASS Site.

    PASS is at a turning point in the organization, with the pandemic and the move of their main fundraiser to a virtual event. Across the last two years, I’ve been a member of PASS, a supporter, and a critic with my own thoughts and ideas about the organization.

    However, I’m not sure where PASS should go. There is a lot of enthusiasm for the organization from some, and no shortage of criticism. I see both sides, but what I’m not sure about is what I want PASS to be or do in the future. I suspect the organization will change, but into what?

    I’d ask that each of the candidates outline a vision for what PASS should be. Not tactical specifics or complaints, but ideally, what do we want from the organization. What would represent the members and be a great community group?

    Hopefully we’ll see something before Wednesday, when voting starts.