Tag: syndicated

  • 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.

  • A Corporate Wellness Day

    Today is the corporate Wellness Day at Redgate. It’s a day off for almost everyone in the company, unless they have something that can’t get moved. A few support people, a few others, like me, that are traveling. We, however, will get another day that we can take off.

    When we revamped benefits for 2023, one of the things that we wanted to encourage was health and wellness. We added a couple days off, like this company holiday and a birthday day off. We also reduced the ability for employees to get out of vacation by not buying back days and emphasizing that managers should ensure they work with people to take their entire allowance. We can carry over 5 days, but no more.

    I like the idea of this day off, as it means people take some time away and won’t come back to a bunch of emails or other things that people sent during their break. Instead, the company is essentially shutting down.

    I don’t mind missing today for travel. I’ve got things to do and I’m looking forward to working with a customer tomorrow. However, I also value my days off and I am looking to try and get a day later this week or next and get up to the mountains.

    Whether you think this is a good idea or not, I would hope you admit that it’s nice that the company is trying to ensure employee wellness. Last week had a number of meetings for Mental Health Awareness Week, and to cap off those efforts, we close today.

    I’ve never had a corporate closure like this as a benefit. I’m looking forward to next year and taking the day off with everyone else.

    I hope.