Choosing Sequences Over Identity

When I was building software as a full time job, the choices for automatically generating surrogate keys were the identity property and the NEWID() function. At that time, GUIDs were too cumbersome to deal with, and I often used identity values in tables. I looked for natural keys, but often these were secondary keys for me and I preferred to use numerical values in many tables as PKs and FKs.

In the last few years I’ve run into a few customers that prefer sequences, which are a separate object in your SQL Server database. There are some challenges with sharded systems and using deployment technologies like SQL Compare, which is one reason I’ve avoided them. However, I was reading Dr. Greg Low’s blog recently where he noted that he prefers sequences to identities. He gives a good comparison of the reasons why sequences can be easier to manipulate, with some advantages because these are a separate object. I think he makes a good case why we might always want to consider sequences over identity values in new development.

He’s convinced me, though now I need to learn a new habit and build new skills to quickly and easily develop sequences for table keys instead of relying on identity values. This is a big change for me, with nearly 30 years of writing identity properties in CREATE TABLE statements.

Learning to adopt new techniques and changing habits of the ways that we grow and change, and certainly how we build better software. That’s a tenet of DevOps. Experiment and learn. This is a place where I’ll start to grow and see what I think as I build demos and PoCs for customers, giving sequences a chance. I wonder how many of you might rethink using identities in the future as well.

Steve Jones

Listen to the podcast at Libsyn, Stitcher or iTunes.

Posted in Editorial | Tagged | 2 Comments

May the Force Be With You

I’ve never done much more than give a passing smile when I see all the posts and notes about May 4th from geeks around the world. I was a huge Star Wars fan as a child, and the original is still probably the movie I’ve seen more times than any other. Life has moved on, and while I haven’t been a s big a fan as an adult, being shut in at home has me thinking about Star Wars today, and the good luck saying, “May the force be with you. Always.”

I loved the original trilogy growing up, was disappointed, but slogged through the prequels with my oldest. I watched the Force Awakens in Cape Canaveral with my middle son in the theater after seeing SpaceX launch and successfully recover their first reusable rocket. We were both a little disappointed in that one, not from the effects and action, but more from the writing, which seemed to drag on.

Since that time, I haven’t seen any of the other films in the theater. In fact, I’ve watched most of them on an airplane, traveling from one place to another. Since I’m not traveling now, I’m thinking to actually go re-watch some of these films on a larger screen, with better lighting. I’m hoping some immersion in a series of films will take my mind away from some of the stress and strangeness of the real world.

I’m sure some of you are big fans to this day, some may not have seen all (or any) of the films. Today, as we start another work week, I’m taking a little break from the technical world I’ll spend most of the day in and looking at a fantastic, highly technologically advanced, geeky Star Wars universe. Do you have favorite films or technology? Any films or characters that stand out to you? I have to admit I was always a big fan of the land speeder, though the pod racing in The Phantom Menace was exiting to me.

On this Star Wars day, with a world we might want to forget, share some Star Wars memories today.

Steve Jones

 

Posted in Editorial | Tagged | Comments Off on May the Force Be With You

Executing PoSh line by line in VS Code

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

I’ve had to relearn this trick multiple times, so I decided to write a post. The simple answer is highlight code and press F8.

I’ve come to enjoy writing PoSh in VS Code, but I often end up writing a bunch of the code in a command window, trying out specific things. Often this is because I’m working in a specific folder. Sometimes I’ll get caught up in typing in the VS Code terminal, forgetting to edit the actual script.

Lots of sites have posts on this, but the simple thing is to pick a line and then click F8. The code will run in your terminal window, and you can see the results. Here’s an example for me.

2020-04-21 12_51_44-● $filter = _e__Documents_GitHub_MultiTena • Untitled-2 - Visual Studio Code

You can actually just put the cursor on a line and click F8. I’ve got a short gif that shows this.

poshvscode

The next time you want to work through a PoSh problem line by line, consider using VS Code and F8.

SQLNewBlogger

This is one of those things I’ve googled too many times. So I took 4-5 minutes to just type this up, grab a couple screenshots, and put this together.

It’s focused tightly on one thing, executing PoSh. I don’t need to explain more to show this piece of knowledge, and hopefully remember it in the future.

Posted in Blog | Tagged , , | 2 Comments

Daily Coping 4 May 2020

I’ve started to add a daily coping tip to the SQLServerCentral newsletter, 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 send friends a photo of a time you all enjoyed together.

I take a lot of photos. In fact, I’ve sent a few out over the last couple months as I touch base with some people and check on them. I actually had fun with a twitter thread early this year, looking back at the last decade.

For the SQL Community, here are a few that I want to share (I’ll send out to others).

On the original kilt day:

Kilt day at Sqlpass

The big guy doesn’t love hugs, but he also doesn’t run away

IMG_1941

This guy is always happy. I hope I see him sometime soon.

IMG_1950

I miss Shaw.

Photo Apr 15, 8 28 42 PM

The silliest co-worker

Photo Oct 10, 5 59 09 PM

A technical genius

Photo Jul 13, 3 06 44 AM

#GeauxTigers

Rob_BatonRouge

The photographer posing with me

Steve_rodney_2011

Posted in Blog | Tagged , , | Comments Off on Daily Coping 4 May 2020