Author: way0utwest

  • Identity Values – Dropouts and Spaces

    Identity values are very useful, but there can be misconceptions about the way in which they work. One of the more interesting things that I see people assuming is that an identity value will ensure you have a continuous range of values for that column. They assume that this code:
    CREATE TABLE MyTable
    ( id INT IDENTITY(1,1)
    )
    GO
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    GO
    SELECT * FROM mytable
    GO
    DROP TABLE dbo.MyTable

    It will, and it will get give you a list of 5 rows, with continuous values. Assuming that this pattern continues in your application, you will have a continuous list of values. What about this code?
    CREATE TABLE MyTable
    ( id INT IDENTITY(1,1)
    )
    GO
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    GO
    UPDATE mytable SET id = 12
    WHERE id = 3
    go

    SELECT * FROM mytable
    GO
    DROP TABLE dbo.MyTable

    You’ll actually get an error, since you can’t specify identity values directly, but you can do this:
    CREATE TABLE MyTable
    ( id INT IDENTITY(1,1)
    )
    GO
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    INSERT mytable DEFAULT VALUES
    GO
    DELETE mytable WHERE id = 3
    GO
    SELECT * FROM mytable
    GO

    That will give me these results:
    ident_d
    If I now do this:
    INSERT mytable DEFAULT VALUES
    GO
    SELECT * FROM mytable
    GO

    I get
    ident_e
    My next value doesn’t fill in the gaps.
    An identity value is strictly a “what’s the next number” process. It does nothing to manage the existing values, and it does nothing about filling in gaps. That’s important to know, and to be aware of when designing your database around identity values.

  • Lenovo W510

    I finally ordered a new laptop, a Lenovo W510, that caught my eye. I was thinking the T series 510, but once I added a few things it was the same price as the W510, but had 2 fewer cores. Since I do a decent amount of video stuff, the extra cores should come in handy.

    No word yet on my Toshiba, and I don’t even know what to do with that. It’s been nearly two months, and I’ve missed some things at work without having a machine I can use while traveling and away from my desk.

  • It’s a Toaster

    I had to install WinZip the other day, having the need to unlock a .RAR file. There’s no native support in Windows for those, and I turned to Winzip. I posted a note on Twitter and got suggestions from people for WinRAR and 7-Zip, but this is one of those areas where I don’t think it matters. Or as my business partner says

    “It’s a toaster”

    I know there are all kinds of toasters, some fancy ones, some cheap ones, but for the most part they’re a generic. I don’t know many people that spend more than 10 seconds thinking about what type of toaster to buy. They just buy one.

  • Should You Achieve All Your Goals?

    So many people wrote posts at the end of 2009 analyzing their goals and what they achieved. I did the same thing, and it was a great exercise. It allowed me to look back at what I’d planned on, and see how well I’d done over the year. I’ve known about the power of goals for a long time, ever since I saw the founder of the Discovery Channel, John Hendricks, speak at a corporate event. It was inspiring, and it’s stuck with me for years.

    But should all your goals for the year be achievable?

    I would argue that they should not. If you have actually accomplished all of your goals, or exceeded them, you probably did not do a good job of setting the bar high enough. Especially as you look across a year. Your interests will change, you will enjoy some things more than others, and likely you will exceed some goals and not attain others.

    That’s OK, and as long as you have made some effort and improved yourself, it was a good exercise. I failed miserably at one of my goals in 2009. It was on my mind, but I kept putting it off, and by November I didn’t have the time, energy, or desire to focus on it. And I didn’t want to half-ass it just to check some box. However I exceeded a few other goals, and that made me feel that it was a successful year in terms of goals overall.

    As you set your goals for 2010, and it’s certainly not too late, be sure that you pick some things that will make you work. Things that will stretch you, and things that you want to accomplish in your life. You might not achieve them, and you can analyze that next Christmas, but keep them in mind, and as long as you are moving forward, you’ll be accomplishing something.