Tag: syndicated

  • Practical Problems with CI

    I agree. Continuous Integration has issues in the real world, at least it probably does in many companies. The more tests you have, the more likely you refactoring or changes will break something. The more things break, the more people will look to leave them alone, deferring the "fix" into the future.

    This defeats the purpose of CI. The whole idea is to keep your software in releasable condition. That way you can push it out if you need to.

    How do you deal with the constant build breaks? The first thing I’d do is see if I mad a mistake and can fix my code. That should be the first reaction.

    The next thing is stop for a moment and see what tests are failing. It’s entirely possible that the tests aren’t valid or aren’t needed. Maintenance of tests is an issue. If this is a test that regularly breaks, I might call a quick meeting and see if we should remove it.

    The last thing is that I’d rollback my code and then go back to work on it. Perhaps there’s another way to solve the issue and not break the build.

    This isn’t magic. It’s also not easy. However if you are keeping up with your CI process and it’s healthy, I believe it will pay off over time with better software.

  • SQL Konference 2015

    My first speaking date of the new year is scheduled. I’ll be at the SQL Server Konference 2015, near Frankfurt, Germany. Red Gate arranged things, and I’m looking forward to heading over and renting a car to drive in Germany.

    And speaking, of course.

    I don’t know the agenda or details, or which session I’m presenting, but it’s exciting.

    Slightly bittersweet as I won’t make SQL Saturday #358 in Albuquerque. I’ve been to the last two, taking a day to ski at Taos, but I can’t make it this year as I’ll be speaking that week in Europe.

  • T-SQL Tricks – Custom Templates

    I wrote about the Template Explorer, which comes with the SQL Server tools and is visible in Management Studio (SSMS). It’s handy, but there are limited code items in there. What if I want more?

    That’s easy. Suppose I decide that I often need to create procedures with the EXECUTE AS clause. I usually do this:

    CREATE PROCEDURE MyProc
       @id INT
    WITH EXECUTE AS OWNER
    AS
    BEGIN
    
    -- do work
    BEGIN TRY
    
      COMMIT
    END TRY
    BEGIN CATCH
      ROLLBACK
      EXEC uspErrorHandler;
    END CATCH
    
    END

    It’s a basic template of stuff I do. Let’s stick this in our Template Explorer.

    The first thing I do is go to the Stored Procedure folder. I can right click it and I’ll see this:

    templates12

    I choose template and a new one is created. I enter a name and I have a template. The first 6 templates here are defaults. The last one, highlighted below, is the one I created.

    templates13

    Now I right click it again and select Edit. At this point, it will open in a query window. This is just a file in my file system (under ), and like any other query, I can edit it. I paste in my script from above, and change a few items to parameters.

    templates14

    Now I can save this, and the next time I need this, just drag it into the main window and customize it.

    templates15

  • Use -eq in Powershell

    I was writing a quick script to work with files and I only wanted to process one file for each execution of a loop. I could have done this multiple ways, but I threw this together:

    $fileEntries = [IO.Directory]::GetFiles(“d:\placeholder”);
    $delete = 1;
    foreach($fileName in $fileEntries)
    {
    if ($delete = 1)
    {
    # do something
    $delete = 0;
    }
    }

    When I ran it, it kept deleting everything in the folder. That was really annoying, and it took me a few minutes to spot the problem. I kept thinking my variable wasn’t getting set to a new value, but it was. The problem was it kept getting reset.

    I first changed to this, but that produced a PoSh error. That’s because I’m working in PoSh and not C.

    $fileEntries = [IO.Directory]::GetFiles(“d:\placeholder”);
    $delete = 1;
    foreach($fileName in $fileEntries)
    {
    if ($delete == 1)
    {
    # do something
    $delete = 0;
    }
    }

    Eventually I remembered that I need to compare things with -eq, so I ended up with this, which worked perfectly.

    $fileEntries = [IO.Directory]::GetFiles(“d:\placeholder”);
    $delete = 1;
    foreach($fileName in $fileEntries)
    {
    if ($delete -eq 1)
    {
         # do something
    $delete = 0;
    }
    }