Category: Blog

  • Shutting Down Coping Tips

    It’s been nearly 3 years of Daily Coping Tips here at the Voice of the DBA. I started these when the pandemic hit and the world shut down. I’ve enjoyed them and they have helped me deal with life, and more importantly, think more about life.

    However, they do eat up some time, and I am planning on stopping on Mar 24, 2023. That gives me 3 years of daily workday tips, ending on that Friday.

    Hopefully these have helped you, and if you miss them, feel free to flip through the past ones and see what I’ve suggested and how I’ve implemented the tips.

    If you want to set up your own calendar moving forward, looking for ways to make life better, I’ve been inspired by the Action for Happiness calendar, which comes out each month. I’ve made this one of my wallpapers for the last three years.

  • Adding a Computed Column–#SQLNewBlogger

    Recently I needed to add a computed column to a table and realized that I didn’t remember the syntax. This short post show how to do this.

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

    Adding the Column

    I had a table, OrderHeader, and wanted to add a new column, OrderedByDate. I can do this with a simple ALTER statement and an ADD. The inserting part is the computation. You use as AS clause with the computation instead of a datatype. For example, my code was:

    ALTER TABLE dbo.OrderHeader 
       ADD OrderedBy AS OrderDate;
    GO

    This added a copy of my OrderDate column with a new name. This is useful for zero downtime deployments in some cases, and in this case, I wanted to just have a copy. However, if I wanted some calculation, I could easily do that by specifying this as I would in a SELECT statement. For example, if I wanted the computed column to be a week later, I could do this:

    ALTER TABLE dbo.OrderHeader 
       ADD OrderedBy AS DATEADDD(DAY, 7, OrderDate);
    GO

    This would add a week to the original value and return that. I can likewise do any sort of string or numeric manipulation I want. A common one is adding or multiplying two columns together for a new value. For example, adding various charges for a total in an order.

    When you do this as a computed column that is not persisted, no space is taken in the actual table rows. If you persist this, then space is used.

    More information on Microsoft Learn.

    SQL New Blogger

    I realized that I needed to double check the syntax in the docs, and when I did, I took this as an opportunity to write a short blog post. I grabbed a link, wrote some code, and then spent 10 minues knocking out this post.

    If some employer does this a lot, they might search your blog to see if you can do this. A nice few posts on how to do this, what persisted does, how you index this, etc. Take a few minutes and start blogging on topics like this throughout your week.

  • Daily Coping 1 Mar 2023

    Today’s coping tip is to call a friend to catch up and really listen to them

    Actually a friend pinged me to ask about a call recently. I made some time and set up a call.

    I’m glad I did. A friend is having changes in life and wanted to talk. I feel similarly, and in this case, we had some similar challenges that we could talk about, support each other, while enjoying catching up.

    Worth the 15 minutes of my life to do this.

    I started to add a daily coping tip to the SQL Server Central 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.

  • Daily Coping 28 Feb 2023

    Today’s coping tip is to thank three people you feel grateful to and tell them why.

    This is something I tend to do privately, thanking people who’ve impacted my life. I’ll do that, but in general, here are the people I want to thank.

    Friend 1 is someone I’ve known for many years in Denver. We get together periodically for lunch or dinner, but I’m always happy to have an ear to vent about life, kids, marriage, work, etc.

    Friend 2 is someone I’ve known from my work and community experience who has been a friend and support system in many ways over the years. We’ve had the chance to share some tough times and help each other, which I appreciate.

    Friend 3 is a friend at work who’s been someone that has supported and helped me grow myself as an advocate.

    I started to add a daily coping tip to the SQL Server Central 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.