Author: way0utwest

  • A Day Off(ish)

    I usually don’t post too many things about breaks, but I think that might be a bit of a mistake. I’ve struggled to get away from work at times, as have many others in technology, so I’m making a note here that I’m gone (somewhat).

    I’m in Las Vegas today for a volleyball tournament. A second job for me is coaching kids, so I’m actually working today. This is a busy competition time, and I have a few trips to various places this month, this being the first.

    It’s work, but it’s a nice break from technology and my work at Redgate Software. Wish us luck in the Red Rock Rave tournament.

  • Daily Coping 4 Apr 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 focus your attention on the good things you take for granted.

    My life is amazing, and I’ve said it before, I appreciate it more and more. I have nothing really to complain about. My body hurts at times. Things don’t always go my way, but in the grand scheme of life, my issues are tiny.

    There are things I sometimes take for granted, so I’m listing a few today.

    My hands – this was a tip recently, but an injury to my wrist reminded me of how much I use them and appreciate them. I am being a bit more careful lately in protecting them.

    My body – I’ve gotten used to going to yoga multiple times a week and weight lifting, among other things. In the last year, I’ve had a few instances where I struggled to do those things. I realize that I sometimes take my health and body for granted, and I should be grateful for what I can do.

    My job – I’ve seen more than a few people struggle with bad jobs, bad bosses, and financial insecurity because of their employment. I have an amazing company, boss, and I try to remember that.

    My wife – I appreciate her, I love her, and I value her company and counsel. At the same time, I can take our relationship for granted and not think about how lucky I am and how well our marriage has been for over 20 years. I am trying to stop and remind myself often that I am lucky. I know many people that don’t have that or haven’t found it yet.

    There’s more, but that’s a good list for today.

  • Executing Notebooks in a Stored Procedure

    Jupyter Notebooks are a popular way of consolidating a number of code batches together and them executing them as separate batches or all together. These are essentially a document with notes and code, all of which are stored together. Databricks can run these, as can a number of other services. They are also integrated into various tools, like Azure Data Studio.

    Just like many other technologies, we’d like to execute these in a way that suits our environment. While running these in a tool like ADS works fine, we might want to schedule these and check the results later. You can run notebooks with PowerShell, but keeping around results and managing the data is hard. Since many of us use SQL Server or Azure SQL Database, wouldn’t it be great if we could find a way to have these run inside SQL Server and keep the results around?

    I was poking around inside a database and discovered that I could do this. Only with notebooks that have T-SQL code, but that’s usually what we’d want to do inside a SQL Server (or Azure SQL) database. I need to write a more detailed article on this, but there are a few basics that might help some of you understand how this works. Essentially, there is an undocumented extended stored procedure, xp_notebookparse, that will read the JSON internals of a notebook and allow you to extract out there T-SQL batches. The @execute = 1 parameter will cause each of these batches to be executed.

    For results, a new notebook is created and added to a local temp file, #nbresults, as a BLOB value. You can explore the structure of this, but essentially, part of your stored procedure should take all the data from this table and add it to a permanent table in your database. If you use a stored procedure to wrap the extended stored procedure call and an INSERT..SELECT call together then you’ll actually get nothing to happen because today is April first. It’s April Fools and this is a joke. Hopefully, you aren’t too disappointed.

    Steve Jones

    Listen to the podcast at Libsyn, Stitcher, Spotify, or iTunes.

  • Daily Coping 1 Apr 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 choose to smile today at something you encounter.

    I tend to smile (and wave) at people. And horses. I’ll wave to the horses, which my wife thinks is silly.

    I smile at things I see, though, and often it’s something a kid does. Kids are amazing humans, and they view the world in fascinating ways.

    For me, I was smiling recently at SQL Bits, where I saw people hugging and shaking hands. It’s something I’ve missed at events, the closeness of friends. Most people asked others if it was OK, and for the most part it was.