Author: way0utwest

  • Where Do You End Up as a DBA?

    I saw this question pop up on the forums: Where do senior DBAs land finally? It’s an interesting question, and for people that are searching for the next challenge, I would guess that they’re interested in an answer. Here’s what I think:

    There is no landing, senior or not. There are only stops along the path of your career.

    As you gain experience, and talent, you will have both more, and fewer, choices. If you expect to constantly gain salary, you will find that harder and harder over time. That’s the nature of any business. The best artist/athlete/programmer/whatever will reach a point where they can’t necessarily raise the market price for their services. The more you want to get paid, the fewer people that will afford you.

    If you look at money as a measure, you will be disappointed at some time. Not that money isn’t important, but I recommend you keep things in perspective. Money is important, but as you earn more, I would hope that value would start to diminish.

    At the same time, the challenges and opportunities at a job may matter to you. If you always want a harder problem to solve, a more complex system to manage, you’ll find the same limitations at some point. Fewer and fewer extremely complex (or very large) databases exist. You have less choice if this is important to you.

    Some people are restless and want to look for new opportunities on a regular basis, no matter what their situation. If that’s you, I would think you should consider consulting, either with a company or by yourself. Which you choose probably depends on your tolerance for the non-technical parts of a business, as your own consulting business will have lots of non-technical work to manage.

    Some people value stability, and if you value that highly, you’ll sacrifice some challenge and excitement. However stability is very relative these days, and you need to keep that in mind. You always work for yourself and no job is guaranteed for the rest of your career.

    I have moved back and forth from consulting to FTE, and like both, but I tend to value the co-workers I have and environment more than other things. I have to enjoy going to work. I find the DBA/developer job to be pretty much the same in most places, but my co-workers make the difference.

    It’s good to investigate and consider other options, but don’t think of this as the game of Life, with a few choices and an ending point. There are many paths, many directions to go. Some routes may cross, but many do not. You choose the one that matters to you, but don’t be afraid to cross to another one if you find yourself wanting.

    Where do you think Senior DBAs end up?

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.1MB) podcast or subscribe to the feed at iTunes and LibSyn. feed

  • Powershell Quick Parameters for Scripts

    I was working on a script recently to manage a particular process and wanted to make it generic by allowing the user to pass in a parameter. I have seen lots of examples, especially those that work with SQL Servers, using text files and other items as parameters, but in this case I wanted an easy, quick, command like parameter.

    This post looks at what I chose to check parameters. I had a couple requirements.

    • display message if no parameter is passed in.
    • display some help if /? is passed in.

    I know that my cmdlets should contain help from the PoSh command line, and I’ll get to that. For now, I’m managing things the way I was taught when I wrote C. A /? should get me help.

    $Args

    I did a little research on parameters and found a few things, but decided to use the $args variable. This is an array of undeclared parameters. I grab the first value (the only one I care about like this.

    $instance = $args[0]

    Note the [0]. As with many things in Computer Science, we’re zero based arrays.

    I could allow for other parameters, but this gets me what I want.

    Testing

    The test for /? is easy. That’s like this:

    if ($instance -eq "/?") {
      write-host "Please enter the instance you wish to detach all databases from as a parameter."
      }

    If this is equal to my help request, write something out.

    Next I needed to add another test. In this case I found that I could easily look for NULL variables, or blanks, with the !. As in this:

    if (!$instance -or $instance -eq "/?") {
      write-host "Please enter the instance you wish to detach all databases from."
      }

    That worked well and lets me remind myself if I’ve forgotten to pass in a parameter. The one thing I experimented a few times with was the OR clause. I tried these, none of which worked:

    • if (!$instance OR $instance -eq "/?") {
    • if (!$instance) or ($instance -eq "/?") {
      if (!$instance) -or ($instance -eq "/?") {

    A little experimenting got me to remember that PoSh is fairly consistent, and the plain -or should work inside the parenthesis.

    Everything Else

    When I first ran this without a parameter, my script froze. That’s because I hit the IF clause, wrote out the message, and then executed.

    Fortunately I’ve done this type of stupid programming before, so I added this:

    if (!$instance -or $instance -eq "/?") {
      write-host "Please enter the instance you wish to detach all databases from."
      }
    else {

    The rest of my script fits in the else clause.

    Reference

  • Your Tools

    I was watching a few developers present recently and they made extensive use of tools to make their coding go very quickly. At one point in the presentation, after having shown a very efficient coding session, one of the developers stopped to answer a question. The question was about how the presenter managed to write code so quickly with so few keystrokes. The answer was with Resharper, but I was surprised when the developer went on to say he had purchased the tool himself a few times at different jobs because it was so valuable in hits work.

    He noted that even if an employer wouldn’t pay for them, there are some tools that are really worth buying. They make your job easier, and so much less stressful, they’re worth the investment. He pointed out that mechanics often buy their own tools, chefs buy their own knives, why shouldn’t we buy a few tools ourselves?

    I know early in my career I never would have purchased any tools if my employer wouldn’t. However I’ve matured, and I realize that there are benefits from tools that go beyond what my employer receives. I think that if I were to move to a design role, I’d have to use a tool like ErWin, or at least Visio, to do the job. Even if I had to purchase it. If I were doing T-SQL development, I’d get a copy of SQL Prompt and SQL Compare to make my life easier. If I were tuning code, I’d be sure Plan Explorer was on my machine, and I’d be really grateful to SQL Sentry that it was free.

    I know that many companies don’t like to add extra tools to their systems, but I know I’d find a way to argue that these tools are really essential for an efficient IT worker. At least on developers’ and administrators’ workstations. Without them, not only are we working inefficiently, but we’re also working under more stress and frustration than we should.

    Steve Jones

     

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 2.1MB) podcast or subscribe to the feed at iTunes and LibSyn.

  • Parsing SQL Saturday Data – Looping Through And Loading All XML Files

    After my last post on parsing the XML, I decided to continue forward and get ready to put the data in a database. For that, I’m really looking for this data:

    • event ID
    • session title

    With this, I can easily insert data into a table. I’ll have separate tables for the events themselves and the speakers, but for now, I can easily showcase the titles of the sessions.

    With that in mind, I decided to start expanding my efforts and building a series of loops that get all the data from the XML documents.

    Looping through all files

    The first thing I needed to do was loop through all the files I’d downloaded and get the documents loaded. I decided to use a DO loop for this, since I should be doing this at least once each time. Eventually I’ll add logic to avoid downloading files I’ve downloaded already.

    Here’s the basic code:

    $loop = 1

    $loopend = 450
    $doc = New-Object System.Xml.XmlDocument

    do {
    #start large loop

      # get the filename
      $sourceURL = $baseURL + $i + ".xml"

      # do other stuff

      $i++

    #end outer loop
    } while ($i -lt $loopend)

    This is the basis for looping through all the file names, based on my downloads. A quick test shows this is building all the filenames I need.

    Loading files

    The next step is to actually load each XML file in and start querying it. I changed from the parsing code to use a loop since I’ll need to insert each item separately and I don’t think the code I had from the previous article will work. At least, I haven’t found a way.

    If you know of one, let me know.

    I used the Test-Path method to be sure that the XML exists, as there was at least one lost event in my initial download. I think that’s fixed now, but in any case, I added this code:

    #test the path first. If it exists, load the XML
    if (Test-Path $sourceURL) {
      $doc.Load($sourceURL

    #trap the event number. This will be the ID I use in the database table.
        $event = "SQL Saturday #" + $i

    That seems to work fine, and with with $event variable, I know which event the sessions are associated with.

    Next Steps

    That’s all I wanted to put here, giving me a nice, simple way of going through a series of files in a pattern. From here I’ll add more detail to the inner loop that gets the session titles out of the XML document and displays it.