Daily Coping 1 Dec 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 set aside regular time to pursue an activity you love.

For me, I don’t know I love a lot of things, but I do enjoy guitar and I’ve worked on it a lot this year. The last month, I’ve let it go a bit, but I’m getting back to it. I try to remember to bring it downstairs to my office, and I’ll take some 5-10 minute breaks and play.

I’ve also started to put together a little time on Sat am to work through a course, and build some new skills.

Posted in Blog | Tagged , , | Comments Off on Daily Coping 1 Dec 2020

Basic JSON Queries–#SQLNewBlogger

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

Recently I saw Jason Horner do a presentation on JSON at a user group meeting. I’ve lightly looked at JSON in some detail, and I decided to experiment with this.

Basic Querying of a Document

A JSON document is text that contains key-value pairs, with colons used to separate them, and grouped with curly braces. Arrays are supported with brackets, values separated by commas, and everything that is text is quoted with double quotes.

There are a few other rules, but that’s the basic structure. Things can next, and in SQL Server, we store the data a character data. So let’s create a document:

DECLARE @json NVARCHAR(1000) = N'
{
  "player": {
             "name" : "Sarah",
             "position" : "setter"
            }
  "team" : "varsity"
}
'

This is a basic document, with two key values (player and team) and one set of additional keys (name and position) inside the first key.

I can query this with the code:

SELECT JSON_VALUE(@json, '$.player.name') AS PlayerName;

This returns the scalar value from the document. In this case, I get “Sarah”, as shown here:

2020-11-21 14_58_17-SQLQuery3.sql - ARISTOTLE_SQL2017.Compare2 (ARISTOTLE_Steve (58))_ - Microsoft S

I need to get the path correct here for the value. Note that I start with a dot (.) as the root and then traverse the tree. A few other examples are shown in the image.

2020-11-24 14_49_16-

These show the paths to get to data in the document.

In a future post, I’ll look in more detail how this works.

SQLNewBlogger

After watching the presentation, I decided to do a little research and experiment. I spent about 10 minutes playing with JSON and querying it, and then another 10 writing this post.

This is a great example of picking up the beginnings of a new skill, and the start of a blog series that shows how I can work with this data.

Posted in Blog | Tagged , , , | 4 Comments

Delivering Patches Quickly

I love cars. In my life, I’ve owned and regularly driven well over 20 cars. If I count the ones I purchased for my kids and lightly drove, it’s over 30. Just writing this paragraph gets me a little itchy about looking for another car. Actually, I’m looking lightly now, as I expect two kids to move on next year and handle their own expenses. So, next year I’m hoping to add another vehicle.

Recently I saw a note that there was an exploit against Tesla cars, which are rarely stolen, but there have been a few issues. This one was against the fobs that communicate with the car. Tesla is working on a patch, which is interesting. They’ve not only devised their cars, but also their fobs to get firmware updates. Good, and bad, as this increases attack surface area,

Tesla can patch their cars in real time, and they do this fairly quickly. I have a 2012 BMW, and I have updated the firmware in it, but patches are rare, and most of them seem to be stuck in the “visit a dealer” paradigm. It seems many other makes of cars fall into the same paradigm, and aren’t built for regular updates.

In some sense, this reminds me of the way many people deal with the their SQL Server databases. We put code out there, in tables, functions, procs, etc., and often we struggle to update that code quickly. This becomes especially true with applications that use our objects. I often find that changes seem to come slower and slower over time, much like the traditional way that your car is updated by a dealer only.

Ideally, we’d be able to more quickly update code when there are issues. This is especially true if you have procs or other code that could potentially have security issues. DevOps asks us to move towards this type of flow, making changes, and adjusting quickly. There are certainly still challenges with changing code and adapting applications, but if front end developers and database developers worth together, we can deploy code quicker.

Our customers don’t care about our challenges we face with writing and deploying code. What they want are new features, functions, better performance, and meeting their needs. DevOps helps, but it’s not easy. You have to automate things, deploy code sooner AND be willing to fix your code mistakes. You not only need testing, but testing that improves over time.

It is, however, worth the effort.

Steve Jones

Listen to the podcast at Libsyn, Stitcher or iTunes.

Posted in Editorial | Tagged | 2 Comments

Daily Coping 30 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 meal using a recipe or ingredient you’ve not tried before.

While I enjoy cooking, I haven’t experimented a lot. Some, but not a lot. I made a few things this year that I’ve never made before, as an experiment. For example, I put together homemade ramen early in the pandemic, which was a hit.

For me, I had never made donuts. We’ve enjoyed (too many) donuts during the pandemic, but most aren’t gluten free. I have a cookbook that includes and one for donuts. It’s involved, like bread, with letting the dough rise twice and then frying in oil.

I told my daughter I’d make them and she got very excited. I didn’t quite realize what I’d gotten myself into, and it was hours after my girl expected something, but they came out well.

20201115_190346

It felt good to make these. My Mom had made something similar when I was a kid, but I’d never done them until now.

Posted in Blog | Tagged , , | Comments Off on Daily Coping 30 Nov 2020