Category: Blog

  • Beware the Windows 8.1 Update Upgrade

    I had Windows 8.0 on my laptop, and went to Win 8.1 earlier this year. Everything went well. Even this spring, when I installed the 8.1 update, things went well on my laptop. This was my test environment, as most days I work on my desktop. I decided to then update my desktop, and things went well overall, until I went to use SQL Server.

    At first, I couldn’t connect to SQL Server from SSMS. No big deal, I thought the update had stopped a service. I checked Services, and was surprised to not see a SQL Server database service. I had a browser and VSS service, but nothing else.

    I rebooted my machine, which didn’t help. I manually ran sqlservr.exe, and it failed with permissions issued. I tried repairing the SQL install, but that didn’t work either. More than a few people reported similar things, but nothing I found on the Internet worked. I kept getting security SPID errors, so I just uninstalled, and then reinstalled SQL Server.

    I’m not sure under which accounts I had my service running, and it’s possible I used my own account, but usually I set up a SQLService account on my machines. In any case, it was a hassle and pain.

    I’m not telling you to avoid the 8.1 Update, but I am warning you and noting that you might want to be sure you have good backups of your systems.

  • Filetable–Nesting folders and files

    In previous posts I showed how to create a folder in a Filetable and also how to the create (and move) files into the subfolder. However I didn’t repeat that and wanted to test the ability to actually nest things further. With that in mind, I’m going to take this to the next step.

    The Scenario

    What I’ve got is a subfolder in my Filetable called Books. This is the first level below the root of my Filetable share. This folder has three files in it.

    filetable_j

    One of these is the image of a circle, and the other two are images of book covers. I’d like to create a folder called “Covers” and then move the two jpgs into that folder together. Let’s see how this goes.

    The Solution

    The first set of code I want to run will create a folder, but it will have to be nested under the Books folder. As we can see from the table, the Books folder already exists and needs to be the parent_path_locator for my new folder.

    filetable_k

    The highlight shows that “Books” is in the root of my Filetable.

    Here’s the code, which calculates the new path_locator using the path_locator of “Books” as a base and then inserts a new folder.

    DECLARE @path HIERARCHYID
    DECLARE @new_path VARCHAR(675)
     
    SELECT  @path = path_locator
    FROM    dbo.Explorer
    WHERE   name = 'Books'
    
    SELECT  @new_path = @path.ToString()
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             1, 6))) + '.'
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             7, 6))) + '.'
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             13, 4))) + '/'
    ;
    
    
    INSERT  INTO dbo.Explorer
            ( name, path_locator ,is_directory )
    VALUES  ( 'Covers', @new_path, 1 );

    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, “Courier New”, courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }Once that’s run, I see this in the table:

    filetable_l

    The two highlights are the same values, with the parent of the Covers folder matching the path of the Books folder. In the Books folder we see:

    filetable_m

    Things look good so far. I can programmatically nest folders. Now I need to move the two jpgs into the proper folder. Let’s do that in one (hopefully) statement.

    We use the same code as we did to move a file, but this time instead of a variable for the new path, we embed this in the update statement. In this case I actually moved all three files.

    DECLARE @path HIERARCHYID
     
    SELECT  @path = path_locator
    FROM    dbo.Explorer
    WHERE   name = 'Covers'
    
    Update dbo.Explorer
          SET path_locator = @path.ToString()
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             1, 6))) + '.'
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             7, 6))) + '.'
            + CONVERT(VARCHAR(20), CONVERT(BIGINT, SUBSTRING(CONVERT(BINARY(16), NEWID()),
                                                             13, 4))) + '/'
    
          WHERE RIGHT(name, 3) = 'jpg'

    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, “Courier New”, courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }The table now shows:

    filetable_n

    The shaded values, while very long now and truncated in the image, are in fact the same.

    The share shows:

    filetable_o

    and

    filetable_p

    I could certainly have accomplished this in other ways, but being able to do this in T-SQL is a nice way of managing your files in a simple way that might be easier than changing an application. It’s certainly a good way to fix incorrect data if the application can’t do it and this can be much faster than having a user move lots of files manually.

  • Sabbatical – Back to College

    My employer, Red Gate Software, offers a sabbatical to their employees, and this year I’m taking mine. I’ll be gone from June 2 – July 14, away from work, but I’ll be blogging here about my experience.

    I wrote recently that I had decided on what to do for my sabbatical, and the first item on the list was learning something at a local college. Red Rocks Community College is renowned for their Fine Woodworking program, and I decided to take a class this summer from them.

    The first step, however, was to register for college. That meant filling out an application and hoping that this would be smooth. While I wouldn’t mind taking the ACTs and seeing how much knowledge I’ve retained over the years, I’d prefer to have this happen quickly.

    The process was fairly easy. I applied online, filling out lots of forms and the submitted them.

    And waited.

    I had thought I’d be moving in a day or two, but it took a few more than that. However finally I had my acceptance to college and I could get moving. Registering took a bit more time as I had to get through an orientation and take a quiz that helps new students get ready for college, but eventually I was able to register for Fine Woodworking 101.

    It’s an intro class, but all of the really cool classes require this one and the summer actually didn’t have a lot of choices. I thought about woodturning, but decided that with my other project, I should make sure my fundamentals were sound. This also gives me the chance to ask questions if I have issues on my own.

    Step 1, done.

  • Getting Local Books Online

    One of the things that’s annoyed me in the last few versions is that Books Online isn’t smoothly installed for me. I often seem to forget to run through the process, and I’ll find myself on an airplane without being able to check documentation. It’s frustrating and while I’ve muddled through the process, I’ve never documented it.

    And I’m not going to. Aaron Bertrand did it for me for SQL Server 2014. I recently ran through this in a VM that didn’t have the docs installed and it worked great. Along with the 2014 documentation, I also added the 2012 documentation at the same time as I’ve been using this demo VM with 2012 for quite some time and I want to be able to check if behaviors I see are different between 2012 and 2014.

    It’s a simple process, though a touch time consuming. Don’t do this while you’re waiting for a plane. In fact, I’d recommend that you do this early in the morning, when you can let it run for awhile. In a VM, mine took over 30 minutes to get BOL 2014 and BOL 2012.

    When I finished, I could launch the help viewer from 2014 and see both versions of the docs. If I launched the 2012 documentation, I saw thing, this despite seeing both book as “up to date” in the help configuration. I suspect there’s something in the shortcut that would fix this, but ultimately I don’t care. I have BOL installed, and I can just move the 2014 shortcut to the taskbar, since I use it often.