Category: Blog

  • Out of Space

    I’ve used placeholders to ensure I don’t run out of space on my machines. That’s worked well, and usually I can delete a placeholder when I have an emergency, and then clean up the drive.

    However I got a low warning today when trying to do an iOS upgrade.

    space_a

    I’d already removed placeholders, moved all my libraries and downloads to other drives, and installed most programs in other places. However my profiles are still here and they had grown large. I couldn’t really find anything else to delete here that might clean up space.

    I thought about moving profiles, but I saw this post that noted we shouldn’t move profiles. I’m a power user, but I don’t want to debug or rebuild things on this machine, and especially not now. I want it to work.

    That left me with one real choice: upgrade the hardware.

    I asked on Twitter what people liked in SSDs, and got a number of recommendations, but it seemed that Samsung got the most votes in my informal survey. I even got a link to Tech Bargains for drives, but a few of the links I checked went to EBay or similar discounters. I don’t think there’s necessarily anything wrong with EBay merchants, but in this case I want the drive to be new, working, warrantied, and shipped quickly.

    Amazon is my go-to place for lots of stuff, partially as a Prime member, and partially because they are so easy to work with. In this case, I saw the Samsung 240GB 840 series for about $135 and decided that was a good move. I don’t expect to put much more on this C: drive, but it might grow a bit. I ordered this, and it should arrive by Friday.

    I also decided since I was upgrading things, and my wife’s birthday is coming, I grabbed an SSD for her laptop along with a 4 -> 8GB memory upgrade. Hopefully that will be a nice surprise for her.

  • Downloading SQL Saturday data

    I wanted to find out how many SQL Saturday’s I’d spoken at and how I ranked with others. I got a spreadsheet from Kendal Van Dyke at one point, but it was quickly out of date. However Kendal mentioned that there was an XML document on the site, and I looked. Sure enough, there is, but it’s separate for each event.

    That makes sense, and it’s fine. I can get the data and put it together. That’s a nice project and I decided to tackle it with Powershell. Certainly SSIS would work, and I may do that as well, or leave it to you to do. There are others that have done this and Kendal has an XLS he’s updated with this data, but this is something I wanted to just try.

    In any case, here was my plan:

    • Download the XML file for each event.
    • Save the XML locally.
    • Parse out the event node, capturing the title and speaker.
    • Load data into a SQL Server database on Azure.
    • Report on speakers and events.

    That’s it, and it’s not a big project, but it does take a little work to get the pieces to work well. I have potential load issues, duplicate data, etc.

    This post will look at just the first and second items, downloading the XML data for each event and saving it.

    Downloading XML – Technique #1

    This is the first way I found to do this, which was interesting. I hadn’t expected this, thinking I’d need to load the XML document and then save it. However the Invoke-WebRequest doesn’t need that. It has this format:

    Invoke-WebRequest $sourceURL -OutFile $DestinationFile

    I can give a source file location (URL) and a destination, and it works. I used this code, and it downloaded an XML file to my local machine.

    # get SQL Saturday data from the site

    $debug = 1;
    # counter for events
    $i = 1
    $baseURL = “
    http://www.sqlsaturday.com/eventxml.aspx?sat=”

    $DestinationFile = “E:\SQLSatData\SQLSat” + $i + “.xml”
    $sourceURL = $baseURL + $i

    # debug information
    if ($debug -eq 1) {
    write-host $DestinationFile
    }

    if ($debug -eq 2) {
    Write-Host $sourceURL
    }

    # Get file from web server
    Invoke-WebRequest $sourceURL -OutFile $DestinationFile

    Now if I add a counter to increment the $i variable, I’ll get all the files.

    Downloading – Technique #2

    The other way of doing this is to load an XML document from a path. In this case, instead of the Invoke-WebRequest, I’ll use this code:

    $doc = New-Object System.Xml.XmlDocument
    $doc.Load($sourceURL)
    $doc.Save($DestinationFile)

    I create an XML document, load it, and then save it to the path.

    Looping

    In both of these cases, I add a looping item, looking for an error. For me, I decided to use 9999 as the loop terminator. That’s an easy one, since I’m not sure we’ll get to 9999 events any time soon.

    I added this code to the top:

    While ($i -lt 9999) {

    I then covered the load call with a TRY..CATCH.

    try {

      $doc.Load($sourceURL)

      # save file
    $doc.Save($DestinationFile)
    }
    Catch
    {
    # if we can’t load the file, assume we’re done for now.
    $i = 9999
    }

    $i = $i + 1
    # end loop
    }

    This worked OK, as you can see, but it failed early on.sqlsatloop_a

    Event 39 doesn’t have an XML file. In fact, the site for SQL Saturday #39 – New York City, fails with an ASP.NET error.

    This isn’t a good design, but it was a good start and allowed me to get moving on the data. From here, I can start working on the parsing and import procedures.

    A better development process might be to encapsulate the download into a separate process and pass in the path, as I can use this same technique to read my local XML files. I should also separate out the save, and the parsing.

    Of course, I need a better way to error handle and loop through files. I don’t want to download all the files every time, so I think I should have some parsing of my file system, finding which files I’m missing, and then ignoring those in my loop. I should also be limiting my downloads based on some number, which I’m not sure about how to calculate now, but I’ll think about it. I guess I could increment based on some list, but I’d have to get one from the SQL Saturday people. Or I could take a high guess, like 500, and just try to load all those files.

    References

  • Saying No – Feb 28 and Mar 28

    I hate skipping events. If I could, I’d go to all SQL Saturdays each year, but I can’t make them all, and I can’t travel every weekend. I can’t really travel two weeks in a row as it puts stress on my and my family, and with our busy lives, it takes me away from the precious little time I have with them.

    This year I’ve already missed the annual trip to Albuquerque. It comes up on Feb 7, but I’ll be flying back from the UK that day, so I can’t make it. I’m disappointed as the drive down, a day of skiing at Taos, and seeing the wonderful hosts in New Mexico is something I look forward to. Hopefully I’ll go back in 2015.

    I’ve also got two other dates that are out. My apologies as I’ve told a few people I’d try to make their events, but I can’t travel on Feb 28 or Mar 28. That means I’m not going to make:

    I’d say I’m missing Vienna as well, and if I could, I’d go there and ski, but I was tempted by Pordeone and a weekend with my wife in Italy. However I have a few kid events, and my trip to SQL Bits involves a stay into the following week, so adding 3-4 more days isn’t something I can (or want to) do.

    In March, my kids are on vacation and with some family coming into town, I can’t travel then, either.

    This year seems to have a strange schedule to it. Not many events spread out, with most of them being bunched up into a few dates this spring. That limits my flexibility, but that’s a me problem, not anyone else’s issue. However it does mean that I don’t get to see as much of the amazing SQL Server community this spring. As of now, I don’t have any SQL Saturdays in the first quarter.

    I’m still planning April and May, and I’m hoping to get to a few other events. I’m also hoping we’ll see a few more SQL Saturdays pop up and I’ll still get to 10 this year.

  • SQL Bits XIV

    I’m heading back to London for SQL Bits XIV in March. This is my favorite conference, and I’m excited and honored to be selected to present.

    This year the conference goes to four days, and it’s an amazing set of sessions being offered at a very reasonable price. You can get a full day of expert level training on Wednesday and Thursday if you like. Friday is very low cost, and Saturday is free. Thursday also has a few side sessions if you’d like to attend a variety of different things during the day.

    I’ll be presenting Thur afternoon and Friday afternoon if you’d like to see me, but please feel free to stop my, shake my hand, and say hi at any time. I should be at the venue early Thur and the rest of the conference until Sat late afternoon. My sessions hare:

    • Branding Yourself for a Dream Job – Thur, 4:00pm
    • Get Testing with tSQLt – Friday, 5:00pm.

    That doesn’t leave me a lot of time for Friday night’s preparations, so perhaps I’ll preview my costume early.

    Superheroes

    One of the best parts of SQL Bits is that there is a themed party every Friday night, and everyone’s invited to have fun. I participated in the medieval theme a few years ago, but wasn’t ready for Steampunk last fall.

    However I’m ready for 2015. I’ve ordered a costume, with time to change something if things aren’t fitting properly.

    I’m excited to see what people choose, and it should be great fun in London this March.

    This really is a great event. Lots to learn, lots of fun, and a casual atmosphere that I rarely see elsewhere. I thank the SQL Bits team for their hospitality and I look forward to another first class event.