Author: way0utwest

  • Back From Vacation and Ready To Go

    It’s been a good holiday for me. I had a week’s vacation with just my wife, a nice holiday with kids, and a relaxing week where I’m trying to get a few things done. I’ve been away from my home office for two weeks, and it often takes a few days to get used to focusing again at the computer, but I’m getting there. It doesn’t help that the office, err, house is full of people with my kids away from school.

    The year is coming to a close, and it’s a slow week, as I noted yesterday. However, I’m refreshed and recharged. Getting away on an adventure, without a computer to spent time on was great. I did no work and just enjoyed the time away. That’s how a vacation should go, and it’s the type of trip I need to take more often.

    Now it’s time to move forward again. As I wrote about in my goals post, I’m planning on spending some time thinking how to achieve my learning goals in 2018. Today is that day, with an hour set aside to do a little research for resources and attempting to build some sort of calendar with milestones that will help me move forward. Those are the personal items for my career, tangential to my work.

    The other part of today is really digging into where I want SQLServerCentral to go next year. We need to be mobile friendly moving forward (thanks for the push, Google) and that means some code changes. I want to be more involved here, along with upgrade plans to get us onto more modern platforms. The old SQL2008/WS2003 system works, but it’s not ideal, and we can’t take advantage of newer technologies and opportunities that Microsoft has released. My thought is to add new content and new sections to the site, including some better quiz/test/assessment ways for people to check their skills and work towards their own goals. If you have ideas, let me know.

    It’s been a great year at SQLServerCentral, and I hope you feel the same way. Now, on to 2018 and let’s see where we can go.

    Steve Jones

    The Voice of the DBA Podcast

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

  • The Slow Week

    This is usually a very slow week for most organizations. Staff is on vacation, customers aren’t demanding much, and it’s entirely possible if you’re in the office today that you’re a bit grumpy as Monday was Christmas and many of us haven’t had quite enough of a holiday this year. With many employees in the same situation, and another holiday coming next week, it’s likely that everything in your shop is moving a bit slow. Certainly there are no shortage of people that might be on vacation this week. Usually it’s a ski week for me, but not this year.

    Some of you might be just as motivated to get things done this week as any other. In fact, with less people around, you might even be more productive and perhaps are taking advantage of the time. Others of you might be trying to mosey along through your workday, enjoying a relaxed pace of work.

    I find that this is a good week in the office for me to catch up on some work that might not get a priority the rest of the year. Perhaps there are some processes that I’ve been wanting to automate, but never found the time. Perhaps my automation isn’t quite as robust or resilient as I’d like. These are the times when I can actually make a few changes and try to improve a system for the next year. If I finish early, then I’ll often use this as a chance to learn something or tackle some POC that’s on my list.

    That hasn’t always been the case. My first exposure to SQL Server was with a system that went live on Dec 31 at midnight. In the week leading up to the launch, I was working with various other employees and contractors to get a plan in place for the cutover, including new equipment installed and all the various networking and security changes that were required. It was a busy week for me, and one that sticks in my mind. Despite all the prep work and testing, after turning the new system on we found that it couldn’t handle the load. Rollback wasn’t an option, so my 5pm-2am shift didn’t go as planned. I worked through the next day and into the early evening before being relieved.

    If you have a slower week, consider taking advantage of the time to do something interesting at work and have some fun in a way that might benefit you and your employer down the road with a new script, a stronger skill, or even a better way to handle some task. There are still a few days this week that you can use to try something.

    Steve Jones

    The Voice of the DBA Podcast

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

  • Restoring a Copy Only Backup–#SQLNewBlogger

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    There was a question posted recently at SQLServerCentral about whether a copy only backup could be restore with a transaction log backup from a database. I was positive this could, but decided I needed to repro and test for someone as there wasn’t a good BOL reference.

    The Tests

    Here’s what I did. First, I created a table in a database. I often do this and drop in messages to allow me to track the progress of backups and restores. This post follows my progress.

    The Backups

    Here’s my basic script:

    CREATE TABLE logger(msg VARCHAR(200), msgdate DATETIME DEFAULT GETDATE())
    
    INSERT logger (msg) SELECT 'pre full backup'

    Next, I made a backup and added a message.

    INSERT logger (msg) SELECT 'pre-log backup 1'
    BACKUP LOG nba TO disk = 'nba_1.trn'
    INSERT logger (msg) SELECT 'log backup 1 complete'

    Once this is done, I’m in a state that I expect. A normal full backup, a normal log backup, and some data to help me track where I am.

    Now let’s make a copy only backup.

    INSERT logger (msg) SELECT 'pre copy-only backup '
    BACKUP DATABASE nba TO DISK  = 'nba_copy.bak' WITH COPY_ONLY
    INSERT logger (msg) SELECT 'copy-only backup complete'

    This now means I have an open log sequence in the first log backup (post full backup) and a few log records since then. Some of these are inside the copy only backup.

    Now let’s add more data and make a new, regular, log backup.

    INSERT logger (msg) SELECT 'pre-log backup 2'
    BACKUP LOG nba TO disk = 'nba_2.trn'
    INSERT logger (msg) SELECT 'log backup 2 complete'

    It’s at this point that I have this sequence:

    • Full backup
    • Log backup
    • Copy-Only Full backup
    • Log backup

    The Restore

    What I want to test is can I restore the Copy-Only backup and a log backup? I think I can, so let’s do that. First, restore from the copy-only backup, using the MOVE option.

    USE [master]
    RESTORE DATABASE [NBA2] 
    FROM  DISK = N'D:\SQLServerBackup\MSSQL13.SQL2016\MSSQL\Backup\nba_copy.bak' 
    WITH  FILE = 1,  
          MOVE N'NBA' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2.mdf',  
          MOVE N'NBA_log' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2_log.ldf',  
          MOVE N'nba_mo_file1' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2_mo',  
          MOVE N'nba_mo_file2' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2_mo2'
    ,  NOUNLOAD,  STATS = 5
    , NORECOVERY

    Tip: Always use NORECOVERY

    Now let’s try to restore the log.

    RESTORE LOG NBA2 FROM DISK = 'nba_2.trn' WITH NORECOVERY
    
    RESTORE DATABASE nba2 WITH RECOVERY

    This works:

    2017-12-06 17_57_56-SQLQuery2.sql - (local)_SQL2016.master (PLATO_Steve (63))_ - Microsoft SQL Serve

    That should prove things. Let’s check the logger table.

    2017-12-06 18_00_45-SQLQuery2.sql - (local)_SQL2016.NBA2 (PLATO_Steve (63))_ - Microsoft SQL Server

    That’s what we expect. The final message after log backup2 wasn’t captured in our backup files.

    Copy Only Backups

    What is a copy only backup? If we check the Copy-Only Backups page, we find that this is a regular backup in and of-itself, but it has the restriction that it cannot be used with differential backups. This also doesn’t change the differential bitmap, so that any differentials that are made ignore this backup and go back to include data changed since the last “normal” full backup.

    SQLNewBlogger

    Understanding backup and recovery is critical for a data professional. I’d say this is the most important skill, and it’s always worth writing about. Spend a few minutes reviewing scenarios and creating some posts like this to show you understand how the system works.

  • Back to Work

    It seems like it’s been a long time since I wrote any SQL code or did any work. Two weeks ago I was in the UK for SQL in the City, which was a lot of prep work when I arrived with little actual work on the site or with customers. The few days after the broadcast involved meetings and getting ready for the annual Redgate Christmas Party and company awards. I was hosting, so I had to practice and prep for the night. It went well, with everyone indulging me with an on-stage selfie:

    IMG_3405

    Last week was another trip, my final of the year, but a good one. I was luck to spend a week unwired with my wife in Athens. We enjoyed the time, and got to relax without commitments, something that I don’t do often. We didn’t do much except enjoy the time and sights.

    Now it’s back to work after Christmas. I’m ready to go, though that might have something to do with my body still being on GMT time, but in any case, I’m ready to fire up SSMS and do some work.

    Merry Christmas, Happy Holidays, and Happy New Year to everyone.