Author: way0utwest

  • A Lost Day

    I’m not sure what happened, but I had some sort of stomach bug yesterday. I was up throughout the night in the wee hours of Monday with cramps in my stomach or intestines and feeling miserable. Slightly better at 7:30am, I got up and tried to work. Even made some coffee, got a large glass of water and then realized at 9 that I couldn’t work. Lots of painful cramps, and I’d only managed a few sips of coffee and decided to go back to bed.

    I could have tried to work some, but it was a struggle to concentrate on anything, so I lay in bed, reading a bit, but mostly trying to sleep away my misery. With a long weekend coming up (6 day holiday) and then a trip to the UK the following weekend for SQL in the City, I didn’t need this. In fact, I couldn’t really spare the day as I need to prep SQLServerCentral for my time away along with reviewing and editing my presentation.

    However life gets in the way. I could have stressed and tried to work last night, but I decided that I needed to get better and rest, and I did get to spend a little time with my little girl. She was happy to watch a movie and snuggle in the afternoon with Dad, and so I tried to enjoy that.

    Work isn’t smooth. It has bumps, there are times that I need to work long hours to get things done, working late into the night or the weekends. So I’ve learned to relax and not worry about those days that I need a break as well.  Finding that balance in work and life is important, and health is one of those areas that I think work needs to take a backseat to.

  • HASHBYTES – A T-SQL Function

    Someone was asking if the HASHBYTES function was a good one to use in T-SQL as far as performance goes.. I wish I had a good reference for the function, but the best one I had on SQLServerCentral was this piece on using it to load a data warehouse. I also wrote an editorial on it not working with strings beyond 8k, which seems to be a bug, or a lack of resources devoted to ensuring string functions work with varchar(max).

    The HASHBYTES function returns a hash of an input string. A hash is essential a calculation based on the values of the input, and two inputs that are the same, ought to produce the same hash. One catch with this function is that you provide the algorithm used, which can be one of these:

    • MD2
    • MD4
    • MD5
    • SHA
    • SHA1

    Each of these produces different output, returning a varbinary(max) value. As an example, suppose I hash “Steve Jones”

    SELECT HASHBYTES('MD2', 'Steve Jones') 'MD2'
    UNION
    SELECT HASHBYTES('MD4', 'Steve Jones') 'MD4'
    UNION
    SELECT HASHBYTES('MD5', 'Steve Jones') 'MD5'
    UNION
    SELECT HASHBYTES('SHA', 'Steve Jones') 'SHA'
    UNION
    SELECT HASHBYTES('SHA', 'Steve Jones') 'SHA1'
    
    

    The results look like this:

    MD2

    ———————————————-

    0x27851A666BFCB4A35F971DD742CDA15F

    0x2E978DE4841B1F3651A8DF4B2D2CF5F5C624A76B

    0x75931813C7EAAEAB3CD1D8D621935903

    0x979AC597C05CA6DE3A88C31A456D1125

    As you can see, there’s a different hash for the same value using different algorithms. However if I were to compare the same string to itself, I can easily tell if something has changed. If the hashes aren’t the same, there’s a difference. I’m not sure this is a great use, but the more obvious use is that I can hash a password and then have the user enter their own version, hash it, and compare the results. In this way, the system never needs to know the value.

    Just make sure you use the same algorithm Winking smile

  • The Test of Time

    I'd like to build a "smarter business" that will last for 100 years.

    IBM turns 100, and in this article, they brag about bench pressing more other companies half its age. That’s a great headline, and I still remember when IBM was not only the premier hardware vendor of the computer world, but also the largest software maker as well. The “Smarter Planet” ads that IBM puts out there are great, and they are a diverse company, covering so many different industries and locations that it’s hard to comprehend everything they are working on.

    The culture and mission of IBM has changed in 100 years, but it’s still amazing that the company has survived. I think back to the tech companies of my youth, and many of them are gone. Who remembers 3COM? Anyone set up a Wellfleet router? DEC becoming Compaq, and now HP. Apple is still around, but Sun Microsystems is disappearing into Oracle. Microsoft is only 30 years old.

    I once worked for a hundred year old company, one that embraced and remembered it’s history, even as it evolved in the modern world. The President of the company had worked there for his whole career, taking over for his father that had worked there almost his whole life and still came into the office a few days a week at age 80. There was a sense of history, tradition, and pride that kept people working there, with the vast majority of the company having worked there over a decade when I was hired.

    The modern world is fast paced, rapidly changing, and evolving quickly, but there is something to be said for adapting to fit in, while maintaining your mission and ideals. I hope that more companies would look beyond their next quarter or year and make the attempt to build a business that they are proud of, and can survive a hundred years into the future.

    Steve Jones


    The Voice of the DBA Podcasts

  • Cost of the Cloud

    Will we get real time costing of our cloud computing?

    One of the benefits of moving to a cloud infrastructure for IT services should be a reduced cost. The economies of scale for having specialized staff, licensing, etc. are more evident when you have more of everything. The larger you are, the more efficient you ought to be. For some companies, this can be achieved internally because they have such a large number of computers, but for many companies, I think they seriously struggle with the cost of staff and infrastructure for technology.

    A company that looks to build a technology infrastructure has to make an investment and across a short period of time, they are locked into the hardware that has been purchased. Often we find individual departments are unsure they are receiving a fair share of the IT services, which has resulted in large chargeback systems being implemented that usually have a lot of overhead.

    Microsoft appears to be trying to deal with this in an interesting way. It has collected, and published, very detailed data on how the services in its data centers are being used. These are essentially a private cloud for many business units at Microsoft, and the ability to see how costs are being spent in applications, services, even help desk tickets, which can drive behavior.

    Developers now have an incentive to build better applications, since the cost of a poorly performing application is more easily determined. I would even assume that accounting for metrics in development environments should help people test different solutions, and perhaps even start to determine when one should spend more time optimizing code and when someone should allocate more hardware.

    I don’t know if other cloud computing vendors will start to offer detailed use analysis and charges for the use of their services, but I expect that if they did, it would be something that many CFOs, and CTOs might want to see in analyzing the value they get from their public, or private cloud infrastructures. I know that I’ve found value in all the detailed metrics that we get in costing SQL Server queries through DMVs, wait states, and other metrics, which can certainly help one write code much more efficiently.

    Steve Jones


    The Voice of the DBA Podcasts