Across the Water Again

I’m in the UK again, for my second trip this year. This time I have no commitments for speaking or presenting anything. I’m in town for a Marketing get-together and our internal Level Up conference. Nice to be here without being responsible for anything, which is rare.

It’s a relatively quick trip for me. No Mrs. way0utwest Sad smile, but I was traveling last week and next week I take time away to head to Orlando and AAU Girls National Volleyball Championships, so this is slotted around those items.

It’s a relatively busy week, so no sure there will be any blogging for now, but if I come up with something interesting and have some time, I might. I’m focusing on taking a physical paper notebook and pen and trying to do most of my thinking and learning that way.

Posted in Blog | Tagged , , | 1 Comment

Blogging for the Tech Professional at Denver Dev Days

For those that attended my talk at Denver Dev Days, here are the slides: BloggingFortheTechPro.pptx

A couple interesting questions that I need to add to the deck.

What do you recommend for a student? (or someone early in their career)

This could also apply to someone changing careers or fields. If you don’t have experience, does blogging help?

It does. A blog is your portfolio and it’s a good way to showcase what you are learning, have learned, what you are interested in. This gives you some way to show “experience” even if you don’t have any.

Build a project, explain how you learned something, document your journey. I might think about a wider set of topics rather than deeper on one here, as it’s hard to know what you want to do early in your journey. It’s also a time when you don’t want to limit opportunities, so showcase a lot of different things you’ve worked on.

How do I get better at blogging?

Build a network of people you trust. Let them see drafts, get feedback, and incorporate the feedback into your writing. I would do that in two different ways:

  1. Am I correct in my technical details? To do this, get quality feedback from a subject matter expert. Think senior skilled person evaluating your work here.
  2. Am I explaining things well? Get feedback from anyone on spelling, phrasing, grammar, and flow. Think English teacher feedback here.

How do I justify the time to blog when I’m busy at work?

This is an investment in your career. Doctors, lawyers, accountants, etc. need to work on their careers outside of work. Chefs, mechanics, plumbers do this as well.

Technical people can do this. Take 15-30 minutes a week to do this. Over time, it’s a great way to add richness to your resume and stand out from others.

Do you blog at work?

In general, I make notes and sketches of things at work. 3-5 sentences, some bullet points. Then I would spend time outside of work fleshing out my posts. For examples of how long I spend on things, check out the SQL New Blogger series. If you’re starting out, double my times for yourself.

Posted in Blog | Tagged , , , | Comments Off on Blogging for the Tech Professional at Denver Dev Days

Getting AI Written Unit Tests

As a part of my AI experiments, I decided to ask CoPilot to write some unit tests. Here is what happened.

The Prompt

To get started, you enter a prompt as a comment and put the cursor on the next line. Then I can open the CoPilot completions panel. Here was my prompt:

-- for an orderheader table with orderdate and ordertotal columns
-- write a tsqlt test to ensure that the orderdate is not null
-- and that the ordertotal is greater than zero

Once I completed this, I looked at the results.

The Solutions

The first few solutions weren’t very helpful. I’m not even sure what was the thinking for 1 and 2. Three at least starts to get me to think about different cases.

2023-05-10 14_01_56-● -- for an orderheader table with orderda • Untitled-1 - zerodowntime - Visual

Solution 6 started to have promise:

2023-05-10 14_02_37-● -- for an orderheader table with orderda • Untitled-1 - zerodowntime - Visual

Then solution 8 was here. It opens with a short summary of what to do. Not terribly useful here, as this type of structure is something that a developer learns once and then remembers.

Suggestion 8

The solution was a mix of code and text, which I assume is assembled from somewhere on the web. Leaving aside the problems of Intelletual Property, here’s what I saw. All the results are formatted as code here.

CREATE PROCEDURE [test orderheader columns]

AS

BEGIN

    -- Assemble

    -- Act

    -- Assert

END

GO

```

The test should pass if the column is not null and the total is greater than zero.  The test should fail if the column is null or the total is less than or equal to zero.

OP 2019-09-18: The following is a solution that I put together:

```

CREATE PROCEDURE [test orderheader columns]

AS

BEGIN

    -- Assemble

    DECLARE @columnName sysname = 'orderdate'

    DECLARE @sql NVARCHAR(MAX) = N''

    -- Act

    SELECT @sql = N'SELECT ' + @columnName + N' FROM orderheader'

    EXECUTE sp_executesql @sql

    -- Assert

    EXECUTE tSQLt.AssertEquals @Expected = 1, @Actual = @@ROWCOUNT

END

GO

```

The assert statement will fail if the column is null.  If you want to assert that the column is not null, you can use the following:

```

EXECUTE tSQLt.AssertNotEquals @Expected = 0, @Actual = @@ROWCOUNT

```

If you want to assert that the column is not null and the value is greater than zero, you can use the following:

```

EXECUTE tSQLt.AssertNotEquals @Expected = 0, @Actual = @@ROWCOUNT

AND @Expected = 1, @Actual = (SELECT COUNT(*) FROM orderheader WHERE orderdate > 0)
```

That looks interesting. It’s a set of things I need, but not quite ready for us. However, it has some structure that I can use.

Did It Help?

Yes and no.

There is code I can use. The problem for me is that I need to read through and copy/paste a bunch of things together. I also need to then decide what my test includes, and write more code that might make this work for my particular system.

Supposedly we’ll get CoPilot for our internal systems at some point, where there isn’t a danger of feedback being sent to the public model. I think this could learn to be better and save me coding time if it could see my schema and use that to inform and guide the code it returned for me.

Right now it’s not very helpful, and certainly at this time, it seems like it slows me down. However, maybe some of that is me learning to use it more and some is the model getting smarter (or more tailored).

Still, an interesting experiment.

Posted in Blog | Tagged , , | Comments Off on Getting AI Written Unit Tests

What’s Your Job?

There are a lot of technology people looking for jobs these days, especially after all the layoffs that have occurred in 2023. At the same time, I have a number of friends and clients that are struggling to hire qualified people. They get lots of candidates, but they are dismayed at how little the candidates they interview seem to know, or at least how little candidates know in the areas that their organization has needs.

Today, I want to help people get better at growing and managing their careers. Therefore I’m asking those of you that are employed to describe your job. Give us your title in the comments and then list 5-10 things that you’ve done lately. What types of queries have you written? What tasks did you complete with SQL Server or Azure SQL? Have you needed to research something to solve a problem? What knowledge or concepts helped you complete a task?

The idea is to share some of the skills or concepts a person should have to grow their career. Hopefully, some people will then read descriptions and build skills from this list. They’ll try to accomplish the tasks you’ve had to finish, hopefully documenting or blogging about their work.

As an example, I’ll give a few tech things I’ve seen lately from clients. These are practical things someone needed to finish, or something they asked someone else to do.

I was working with a client and there was a need to find all the logins whose passwords were not set to expire. How can you do that?

Another had a table had a lot of duplicate data, and all duplicates but the row with the latest date needed to be deleted. What does the DELETE statement look like? Caveat, what if I need to update all but the first row (newest) with a new value in some column to mark them as inactive?

A client needed to get a list of all the servers from their central management server (CMS) and then extract that list as a CSV file. They were using this for some audit purposes.

At another client, a developer needed to clone a git repository and then open the .sql files in Azure Data Studio. Can you show how to do this?

A DBA wanted to decide whether you choose a clustered or non-clustered index for a table that contains sales information and is often queried for a few rows based on a date. Why would one index be better than the other?

Don’t answer these questions, as this is homework for others. However, if you could share a list of things you would expect your new coworker to know or solve, that will help us raise the bar for what we expect from our colleagues.

Steve Jones

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

Posted in Editorial | Tagged | 1 Comment