Author: way0utwest

  • The Matrix

    Do you want the red pill or the blue one?

    Many of us know the famous scene in The Matrix where Neo decides if he will come out of his dream. We also see the exciting moments in the movie where he has various martial arts downloaded to his brain, and discovers he “knows kung fu” in a small fraction of time. Certainly he doesn’t ever need to physically practice the art, but much of learning is comprehending and understanding a subject in our brains.

    We aren’t at the point of desiring a skill and purchasing a download. Yet. However there is research into using various types of stimulation to actually help improve learning and training. Using pilots and flight training, a complex and varied skill involving both physical coordination and mental understanding, the researchers think they can affect learning. Which is amazing.

    This is barely scratching the surface of learning directly in the brain, but it is interesting to see people researching the topic. After all, this is an area that ought to be of great interest to those of us working in technology, where the acquisition of new skills is important. Few of us do it well, and any improvement that could dramatically improve our capabilities to adapt and grow as technology rapidly advances, would be welcome.

    Unless it involves electrical shock potential. In that case, I’ll stick with my slow read-and-practice method for learning new skills.

    Steve Jones

    The Voice of the DBA Podcast

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

  • The Math on Automation

    I wrote a piece on automation and time savings, and of course, Derik Hammer had to point out another post and xkcd cartoon that splashes some reality on automation. I’ve included it below, and certainly there are some good points made in the cartoon. It is incredibly easy to underestimate the amount of time it takes to complete a software project, especially when you include maintenance. Make no mistake about it, scripting little tasks and adding code into SQL Agent jobs is building software.

    The decision to undertake automation shouldn’t be strictly made on the math of time savings. There are a number of other gains to consider. The post linked above notes that the fact that interruptions can be minimized through automation can be very valuable. I know many people discount the cost of disruptions, but they can be high, especially for knowledge work. This reason alone might be worth spending time on automation.

    I feel that building some automated processes is a great way to actually practice skills you might use elsewhere. Automating tasks is practical, and even if the exact method isn’t a technology you regularly engage in, the mental practice of working through a problem and developing a solution is valuable. Just engaging your brain on a problem can be a good use of some time.

    Those people that have followed the ideas in DevOps for years know that one of the main powers of automation is consistency and repeatability. We know that humans are bad at being consistent and reliable, and those are the places we should use computers. Even if the time savings don’t directly add up, I’m sure the chance of you breaking something, forgetting a step, or even neglecting a task are likely work a little bit of automation time in your job.

    You don’t want to get caught up cerating a large side project to automate something, but little scripts to save time are definitely valuable.

    Steve Jones

    The Voice of the DBA Podcast

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

  • SQL Source Control v5.0 Beta–First Migration Script

    I joined the beta program for SQL Source Control recently. I know, I work for Redgate, I should be in all beta programs. However I present on our various products, and I need those presentations  to work reliably. As a result, I rarely get ahead of our RTM products because I value stability.

    However, I really, really like SQL Source Control, and wanted to get the migrations stuff working in Git. Of course, I’m also looking for holes and problems, so I’ll be giving feedback.

    Install is simple, though after I download the beta, it took me a week to get going because of other tasks. In the meantime, there were updates. I always check for SQL Source Control updates, and I had to download and install an update. Redgate operates on a very agile, DevOps development cycle, so always check for updates.

    2016-03-11 12_27_35-Settings

    That was easy, other than the SSMS reboot. Here are the versions of SQL Source Control:

    2016-03-11 12_29_14-About SQL Source Control

    And SSMS:

    2016-03-11 12_29_25-Settings

    I had a previous database I’ve been using for demos that I keep in GitHub. This hasn’t worked with migrations in the past, but I want it to, so I decided to see how this database would “upgrade” to migrations.

    Syncing from GitHub

    First I created an empty database.

    2016-03-11 12_33_24-Settings[3]

    I then linked this to my git repo. This is easy, but I’ll run through it. I select the database in the Object Explorer (OE) and then click link in the SQL Source Control (SOC) plugin. I’m using Git, so this is a good place to start.

    2016-03-11 12_33_38-Settings

    Next I pick the folder and let the system create the link. Note this repo already is updated from the remote (Github) and contains all my database scripts.

    2016-03-11 12_34_40-

    Once that’s done, I switch to the Get Latest tab and click “apply” to move all the code to my database. This process reads all the .SQL files and runs them in my database, in the appropriate order.

    2016-03-11 12_34_53-Settings

    When that’s done, I have a database. Simple setup, and this makes it easy for me to get a dev system on a new instance quickly.

    2016-03-11 12_47_44-Start

    Migrations

    Now the fun part. Migrations. I’ve been waiting for this version of SOC to support Git. No message here saying my VCS isn’t supported.

    2016-03-11 12_48_38-SQL Source Control - Microsoft SQL Server Management Studio

    Now I want to create a migration script. There are a lot of things I could do here, but let’s do something simple. I’ll go ahead and add a not null column to my RSSFeeds table.

    Let’s try the designer. This is easy enough to do. We’ll add the last column.

    2016-03-11 12_56_34-Settings

    However we can’t save this:

    2016-03-11 12_56_42-Post-Save Notifications

    This doesn’t work as a script, either. The reason is that SQL Server doesn’t know how to manage this change. What goes in the NOT NULL space?2016-03-11 12_57_31-Settings

    There are lots of ways to do this, but the way many people want to deal with this is”

    • Add a NULL column
    • Populate data
    • Change the column to NOT NULL

    Let’s do that. We’ll use a script to do this:

    2016-03-11 13_07_45-Settings

    This works, but when we go to commit this change, we see this:

    2016-03-11 13_08_09-SQL Source Control - Microsoft SQL Server Management Studio

    The tool lets us know this might cause issues, and we need a migration script. If I click on the the “Add a migration script”, I go to the Migrations tab, where I see the table effected. Let’s select it and click “Create migration script.”

    2016-03-11 13_08_52-SQL Source Control - Microsoft SQL Server Management Studio

    This brings me to the script editor. I’ve pasted in my script.

    2016-03-11 13_09_08-New migration script.sql - JOLLYGREENGIANT_SQL2014.ASimpleTalkDB (JOLLYGREENGIAN

    Note I also need to give this a name. The default isn’t great.

    2016-03-11 13_09_25-Settings

    Once I’m done here, I close and save. Now I can see all the items listed on the Commit tab. I’ll start at the bottom. Here is my data change, which is subordinate to the migration script. I’ve scrolled over to see the actual data.

    2016-03-11 13_09_45-SQL Source Control - Microsoft SQL Server Management Studio

    Now let’s look at the schema. Here the NOT NULL is added, but we know this won’t work. This needs the migration script.

    2016-03-11 13_09_57-Settings

    And here’s the script. This is what I wrote and pasted in.

    2016-03-11 13_10_04-SQL Source Control - Microsoft SQL Server Management Studio

    I commit this, and I’ve got a script. Or do I? Do you know what the issue is?

    It’s that I didn’t set a default. I left this out to show you there’s no magic here. SQL Source Control isn’t doing the work for you of deciding how schemas should change. Instead, you need to write the appropriate scripts. In this case, I’ll acknowledge and commit, which it lets me do.

    2016-03-11 13_15_48-Warnings

    However, this will be an issue, so I’ll add another commit. I can check this in my history tab (I committed too quick).

    2016-03-11 13_36_00-History

    You can see this has added the default. What happens on another machine? Let’s check my presentation VM, which is also updated to SOC v5 Beta (with a snapshot to undo this).

    I created a new database and linked it.  At the bottom of the list of objects, I see my migration script.

    2016-03-11 13_50_44-Win7x64 SQL 2012 Demo - VMware Workstation

    I also see this in the migrations tab.

    2016-03-11 13_50_11-Win7x64 SQL 2012 Demo - VMware Workstation

    Applying all changes worked. If I look at the table, I see what I expect, with the the NOT NULL setting, the data, and the default is set correctly

    2016-03-11 13_56_02-Win7x64 SQL 2012 Demo - VMware Workstation

    This is a very basic look at what’s happening with the new SQL Source Control v5. It’s in beta, and if you’re interested, we want more testers and lots of feedback. We’re excited about this release, but we want to ensure it’s the best there is.

  • Working on the Road

    I spend a decent amount of time on the road, traveling to events. Last year I think I spent 50 nights in hotels for work. That’s a fair amount, and it can be challenging to get everything I need to accomplish done in those situations. I’ve gotten good at ensuring my laptops are setup, I have cloud copies of information, or VPN access to files. While I miss my multiple monitors at home, I can work on the laptop for a week without too many issues.

    However there’s one thing I often do before trips: I prep. I get most of my tasks scheduled; I pre-build and prepare newsletters. In short, I try to minimize the work I need to do on a deadline when I’m traveling.

    This week I have a slightly crazy week.

    • UPDATE Monday, I was supposed to be in Fort Collins, CO, with the State Knowledge Bowl competition for my son. However he had other work to do and decided to focus on his classes, so I went skiing 😉
    • Tuesday, Fort Collins, CO – morning work in the hotel, afternoon Knowledge Bowl competition, evening, a bit more work.
    • Wednesday, home office – Daily work and routine
    • Thursday, Spokane, WA – Hotel working
    • Friday, Spokane, WA – holiday, volleyball tournament for my daughter.

    There’s a level of craziness, with changing locations and working sporadically this week. Tuesday should be a holiday, but I’ll have to work around things. I’ll actually try to do some work on Monday around the competition to minimize the disruptions. I have some meetings I couldn’t easily move, so I elected to just work around Tuesday.

    Wednesday will really be my only normal work day, though I have an evening flight to Spokane, so I will feel some pressure here.

    Thursday is a travel day for my daughter. I’ll be in the hotel working while she wanders around Spokane with her team.

    Friday is a tournament, afternoon wave, so if I haven’t finished everything I need, I’ll be working a bit in the am here.

    Not my kind of week, but I have these happen at times.