Author: way0utwest

  • Accelerating Your Career

    Climbing the ladder isn't for everyone, but that doesn't mean you ignore your career.
    Climbing the ladder isn’t for everyone, but that doesn’t mean you ignore your career.

    I ran across an article on ways to accelerate your career and for the most part I think these are good ideas and suggestions. Networking, finding a mentor, and more will help you no matter what business or field you are working. Some of the advice is geared towards those people looking to climb the corporate ladder and move into management, which is not necessarily what many of us want. If that’s the case, ignore those items. There was one item, however, that I thought was particularly interesting for data professionals.

    The seventh item on the list notes that you should spend 10-15% of your time working on a project that’s outside of the scope of your job or team. That might sound crazy, and even dangerous, but it’s a good idea if your boss isn’t opposed to it. Having knowledge about the way your business works, the way they use data, or solve a problem, could be valuable in your existing job. You might notice a pattern or way in which you could improve either your job or someone else’s. Over time, helping in a variety of departments builds friendships, increases your networking, and might show your boss you deserve a raise.

    Many of us end up working with data as a widget. The job of a developer or DBA is writing code or managing data, and sometimes don’t often think much about the actual industry in which we are working. Gaining deeper knowledge of the way your particular business works means you can better understand why you are asked to solve a particular problem. That knowledge can lead to a better solution. It might also make your job just a little more interesting.

    For the typical US worker, that’s 4-6 hours a week. For the IT person, that might be a little more time, but I think it’s worth the investment. I wouldn’t be overly driven in this area, and if I were working on extra projects at work, I’d eliminate (or cut down) on the time I was spending learning new technologies. Life requires balance, and if you tackle something new in one area, make sure you know what you can give up.

    Steve Jones


    The Voice of the DBA Podcasts

    We publish three versions of the podcast each day for you to enjoy.

  • Does TDE really work on MDF files?

    Yes, it does. However, let’s prove it. First let’s create a database, a table, and enter some data:

    -- create a database
    CREATE DATABASE TDE_Primer
    ;
    GO
    -- create and populate a table
    USE TDE_Primer
    go
    CREATE TABLE MyTable
    ( myid INT
    , myname VARCHAR(20)
    , mychar VARCHAR(200)  
    )
    ;
    go
    DECLARE @i INT = 65;
    WHILE @i < 92
     begin
      INSERT mytable SELECT @i, 'Steve Jones', REPLICATE(CHAR(@i), 200);
      SELECT @i = @i + 1;
     END
    ;
    GO
    SELECT * FROM Mytable;
    go

    If I look at the table, I see my name with lots of data:

    Capture_030

    Now let’s detach the database and examine the results with a hex editor:

    -- detach database
    USE [master]
    GO
    EXEC master.dbo.sp_detach_db @dbname = N'TDE_Primer'
    ;
    
    GO

    I use XVI32 as an editor. It’s free, and you can download it. If I open up my MDF in this utility, here’s what I see:

    Capture_031

    If I search for my name:

    Capture_032

    I find it:

    Capture_033

    This is what I expect, and you should as well. Even without SQL Server, your data files are readable, which is why you must protect them.

    Now let’s attach the file and enable TDE.

    USE [master]
    GO
    CREATE DATABASE [TDE_Primer] ON 
    ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\TDE_Primer.mdf' ),
    ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\TDE_Primer_log.ldf' )
     FOR ATTACH
    GO
    
    USE TDE_Primer
    go
    SELECT * FROM mytable
    ;
    go
    
    -- begin encryption setup
    -- from http://msdn.microsoft.com/en-us/library/bb934049.aspx
    USE master;
    GO
    -- create master key for master
    CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'AlwaysU$eaStr0ngP@ssword4This'
    ;
    go
    
    -- create certificate to secure TDE
    CREATE CERTIFICATE TDEPRimer_CertSecurity WITH SUBJECT = 'TDE_Primer DEK Certificate';
    go
    
    USE TDE_Primer;
    GO
    -- Create DEK
    CREATE DATABASE ENCRYPTION KEY
    WITH ALGORITHM = AES_128
    ENCRYPTION BY SERVER CERTIFICATE TDEPRimer_CertSecurity;
    GO
    
    -- backup TDE cert
    USE master
    ;
    go
    BACKUP CERTIFICATE TDEPRimer_CertSecurity
     TO FILE = 'tdeprimer_cert'
      WITH PRIVATE KEY (
                   FILE = 'tdeprimer_cert.pvk',
                   ENCRYPTION BY PASSWORD = 'AStr0ngB@ckUpP@ssw0rd4TDEcERT%')
    ;
    go
    
    -- check encryption status
    SELECT
        db.name,
        db.is_encrypted,
        dm.encryption_state,
        dm.percent_complete,
        dm.key_algorithm,
        dm.key_length
    FROM
        sys.databases db
        LEFT OUTER JOIN sys.dm_database_encryption_keys dm
            ON db.database_id = dm.database_id;
    GO
    
    -- enable encryption
    USE TDE_Primer
    ;
    GO
    ALTER DATABASE TDE_Primer
      SET ENCRYPTION ON;
    GO
    -- check encryption status
    SELECT
        db.name,
        db.is_encrypted,
        dm.encryption_state,
        dm.percent_complete,
        dm.key_algorithm,
        dm.key_length
    FROM
        sys.databases db
        LEFT OUTER JOIN sys.dm_database_encryption_keys dm
            ON db.database_id = dm.database_id;
    GO
    -- TDE_PRimer and tempdb encrypted
    
    -- detach database again.
    -- detach database
    USE [master]
    GO
    EXEC master.dbo.sp_detach_db @dbname = N'TDE_Primer'
    ;
    
    GO

    I won’t go into all the code, but this encrypts the database, backs up the certificate and then detaches it again. There are a few other things, but I cover them in another post.

    Now let’s open up the file in the hex editor again.

    Capture_034

    It looks the same. It’s not in the image, but just below this you can see the database name. There is a header, which is not encrypted. However when I search for my name, it fails.

    Capture_035

    If you scroll further around, you’ll see that most of the file is now encrypted.

    Capture_036

    Play with this and prove to yourself that TDE does really encrypt things.

  • A Billion Transactions

    These are some of the sensors generating that half billion transactions/day.
    These are some of the sensors generating that half billion transactions/day.

    How long would it take your systems at work to process a billion transactions? You’d expect some, heavily used and highly visible systems to be involved. The stock market systems process billions of trades a day, but I’m sure most of the systems in single companies, even large companies, deal with fewer transactions on a daily basis. A billion transactions a day is 11,000+ transactions a second, sustained across the entire day. That’s a heavy load, but it might be the level of transactions that more and more of us will see over time as our systems gather more data.

    The Microsoft corporate headquarters in Redmond consists of over 100 buildings on 500 acres. It’s grown over the years from its original 88 acres, which is also the title of a story about Microsoft and the relatively unknown work in automating their infrastructure. Not the computer systems their software developers use, but rather their facilities and physical buildings. It’s a fascinating story that outlines the way in which Microsoft saves millions of dollars in maintenance and repairs by using software.

    Across those buildings, Microsoft collects a huge amount of data, from disparate systems, which is the presented to the facilities personnel. The sensors and systems don’t process a billion transactions day; they process half a billion. Still an amazing amount of data, just from physical buildings and the infrastructure that ensures Microsoft employees have a pleasant place to work every day. Using a combination of SQL Server, Office, and Azure, Microsoft has built a software system that corrects many faults itself within sixty seconds. Those that can’t be fixed remotely often end up generating one of the 30,000 work orders produced for personnel every quarter. The system is forecasted to save 6-10% of the energy that might otherwise be wasted with a less efficient system.

    It’s a great read, and perhaps is a good case study for an application that is well suited for cloud services. There are a few great quotes from the article as well that are particularly pleasing to a data professional. “Give me a little data and I’ll tell you a little,” he (Darrell Smith) says. “Give me a lot of data and I’ll save the world.” That ought to be the model for data analysts. As SQL Server professionals and developers, we should be helping others to do just that.

    Steve Jones


    The Voice of the DBA Podcasts

    We publish three versions of the podcast each day for you to enjoy.

  • Upgrading to 2012

    I love this logo, and I love working with SQL Server.
    I love this logo, and I love working with SQL Server.

    It’s been a little over a year since SQL Server 2012 was released in its RTM version. In that time, I’ve been using it on most of my machines for testing and demos. I like working with the new features and enhancements, and I think this is the best version of SQL Server yet. However I also keep a version of SQL Server 2008 running in a virtual machine since this is the version that runsSQLServerCentral.

    In the last three years, we’ve continued to run the site on SQL Server 2008 because it works well. We don’t need the newer features, and since we have a clustered pair of instances, an upgrade would be a substantial cost. That cost is hard to justify when there isn’t a business benefit I can point to. I’m sure we could write more efficient code with the new T-SQL enhancements and improve performance, but since we’ve invested in beefy hardware, I’m not sure we would gain much with an upgrade. Quite a few of the people I’ve talked to in the last couple years feel the same way.

    This week I’m curious to see if any of you are looking to upgrade. I know for new systems it might make sense to just install the latest version of SQL Server, but what about existing systems? The question this week is:

    Are you upgrading any existing systems to SQL Server 2012 and why?

    I’m looking for those drivers that provide enough benefit for you to upgrade. There might be features you are taking advantage of that others can use, so share with us the exact reasons for your upgrade. As budgets shrink, especially for systems that are working well, it can be hard to justify upgrades across the board for all your servers, but there are sometimes reasons to upgrade individual instances.

    Steve Jones


    The Voice of the DBA Podcasts

    We publish three versions of the podcast each day for you to enjoy.