How-Do-I-Measure-My-DBA-Skills-Part-2

You may be wondering, “How can I know what phase of my career I am in? How can I see what the next steps might look like in terms of skills I may need to move forward?”

As people change jobs, the gears of career progression are turning.  Some new roles may be the same as the recent previous one. Some new roles will have larger spheres of influence and some may have better titles that require new skills. Like the gears in this picture, your job roles fit together and show a progression of sorts.

So if you’re a production  SQL Server Database Administrator, what does phase 2 look like in your career? You’ve survived those first couple of years and you would like to know what is ahead. You want to know the answer to the question, “What skills do I need to get to the next level?” Glad you asked.

Production DBA II – 2-4 years of experience

  1. All competencies from the previous level.
  2. Assist with triage of user issues, job failures and reactive tickets.
  3. May participate in the design of a backup/restore strategy.
  4. Improves existing processes for ongoing SQL Server management, such as configuration changes, in response to ongoing issues.
  5. Installation of new SQL Server instances without supervision.
  6. Looks critically at patch release notes to advise when a security update, cumulative update, or Service Pack is critical to apply and applies those patches to production.
  7. Demonstrates understanding of high availability and disaster recovery technologies and participates in troubleshooting related issues. (DB mirroring, replication, log shipping, potentially AlwaysOn AGs)
  8. Contribute to automation, particularly using T-SQL and PowerShell.
  9. Familiarity with Windows Performance Counters and how to leverage monitoring software to assess performance.
  10. May participate in T-SQL development of stored procedures, triggers, views, etc as well as database design.
  11. May write and troubleshoot basic SSIS packages and handle deployments for SSIS.
  12. Some familiarity with SSRS development and administration.
  13. Participates in SQL Server migrations with some guidance.
  14. May begin leading in knowledge sharing in some capacity in one or more areas from level I or II.
  15. May take an active interest in leadership and in development of leadership skills, including emotional intelligence.

In phase 2, skill and job functions that you were doing all the time, like handling initial triage of break/fix issues, may be things that you assist other people with rather than have the sole responsibility for yourself. Activities you were doing under guidance during phase 1, the first few years of your career, you will do now with less guidance because you’re better at it and people can see that you’re better at that particular thing. This might include something like installing and configuring SQL Server on a new instance. In phase 2 of your career you may still reference someone else’s guide for this process, but no one is going to be watching you while you do the work.

At this stage you also begin to be more of an independent contributor. You will start to independently recognize opportunities for and make changes in the SQL Server environment that will benefit performance or some other aspect of database management. Automation of work will be something you begin to make your own contributions in, whether that’s automating something with T-SQL, or a new skill showing up in this part of your career, like PowerShell, SSIS, or SSRS.

If you’re fortunate, in this part of your career the more Senior people will be leading a SQL Server migration project.  When you were in phase 1, you only vaguely knew this sort of thing was being worked on and you certainly weren’t working on the project with anyone.  Here in phase 2 of your career, you will likely be given at least some smaller tasks to do related to a larger task, like a SQL Server migration.

Participating in a migration project is great for your skill and career development  because it is usually at least a moderately complex operation to migrate a SQL Server.  This means more people are needed and more parts of the SQL Server management skill set are touched on during the work. A project like this also means more exposure to working directly with the more Senior people, which will get you noticed.

As you stay in phase 2, you will gain increased proficiency at tasks from phase 1 of your career.  This may lead to you occasionally teaching others what you know about those skills and those work activities. Some leadership skills and opportunities may begin to develop from teaching others what you know.  You have to demonstrate good people skills as you teach technical subjects and people may begin to think of you as something of a leader.

Next Steps to Take

  1. Copy/paste the above numbered list to a Word doc.  Think carefully about each one and whether or not you currently meet this criteria.  Put an “X” next to any item you need to work on.
  2. For each item you placed an “X” next to, create a plan for improving skills related to that item. If you’re not sure what Log Shipping is or you don’t know anything about how to use PowerShell with SQL Server, then open your favorite search engine and look around.  There will be people and tutorials that explain it. Maybe you know SSIS or SSRS are used at your company and you’ve always wanted learn the technology.  Perhaps your company has monitoring software for your SQL Server environment and you have been interested in learning how it works. Put these things on your training plan that you’re making in this step.
  3. If you would like help with anything in this post, or with something else related to SQL Server, reach out to me here, and I’ll be glad to offer assistance.

How Do I Measure My DBA Skills Part – 1

 

Career development and progression is a hot topic for everyone.  It starts really early in life like when some adult asked you, “What do you want to be when you grow up?” You might have said “firefighter”, “ballerina”, “ice skater”, or “gymnast”.  I’m certain you didn’t say “DBA”, but here you are anyway, at my blog, trying to figure out a career as a Database Administrator.

So, what does career progression look like for a Database Administrator?  How do you move forward in your career with SQL Server? What skills should you have at year 2? Year 5? Year 10? This post will help you answer those questions.

There are all kinds of DBA’s who do all kinds of different work.  That was the challenge of coming up with the information I’m going to share with you over the next several posts. I chose to create two separate career path skill lists.  One for a production DBA and one for a Development DBA. The primary reason for this is that people typically become a DBA through one of two paths – Systems Administration and Developer.

Were you a System Administrator or Network Engineer when you got your start? You will probably become a Production DBA.  Did you get your start as a .Net or Java Developer? You’ll likely be more of a Development DBA. Different specialties within those general paths can develop from there.

So, here is the first level of skills for a production DBA. Look it over, ponder it and see what you think about the list.  Keep in mind, this is level 1, the entry level Production DBA skillset. I’m trying to answer the question, “What does a beginner Production SQL Server Database Administrator do and what skills should they have?”

Production DBA Level 1

  1. Production DBA – 0-2 years of experience
  2. Handles level 1 triage for things like SQL Server Agent job failures, user issues, and reactive tickets.
  3. Installs SQL Server instances following a process designed by others.
  4. Manages most administrative aspects of non-prod environments with assistance from more experienced DBAs, including the application of patches to pre-production.
  5. Carries out defined tasks like managing new users, running established audit processes, restoring databases to non-prod environments as required.
  6. Basic T-SQL development. SELECT, INSERT, UPDATE, DELETE
  7. May participate in SQL Server migrations in a guided manner.
  8. Demonstrates understanding of backup/restore processes.
  9. Demonstrates values driven behaviors such as humility, integrity, teamwork and is teachable.

A beginner production DBA should at some point be handling break/fix triage work.  This will often coms in the form of SQL Server Agent job failures and requests from users that often say little more than, “It’s broken” whatever “It” is.  At this level, you may have a more senior level DBA hand you a guide and say, “We need a SQL Server installed. Here are the instructions for that. Please have this done by noon.”  You need to understand enough to get through that task successfully.

At least some beginner DBA’s maybe be given one or more non-production environments that they are the primary DBA for.  This provides a mostly safe place for mistakes to be made and for learning to occur. The environment isn’t production so you aren’t going to break anything that is used by external customers.  Now, you might break something that the Developers are using, but that’s less impactful than breaking external customer technology. Managing a non-prod environment gives you a place to learn the other skills in this list.  Developers will need new Logins and Users created as they build new applications.  They will need data refreshed from production and so at this level, you’ll get experience with restoring backups and you will have the opportunity to grow you skills with T- SQL.

Now about that #9 you see in the list –  “Demonstrates values driven behaviors such as humility, integrity, teamwork and is teachable.”

If you thought you would get a job in technology so you didn’t have to deal with people or work on your people skills, I’m hear to tell you that you’re mostly wrong.  Sure, you can be that person who hides in their cubicle and pushes off the “people” part of their job to someone else.  But, it is unlikely your career is going to progress all that far with that approach.  You’re going to need to know how to interact appropriately with your direct co-workers on your team, Developers, DBA’s, end users, your boss, vendors, etc.  So, if you suck with your people skills, get a good book, or two or three, and incorporate that knowledge into your life.  Click here for a book I recommend and look at the other suggested reading at that bottom of the page. A primary reason I really recommend the book by Travis Bradberry and Jean Graves is that it gives you concrete examples not only of high and low emotional intelligence, but specific actions you can take to improve your people skills.

Next Steps to Take

  1. Write down the list above, or copy paste to a Word doc.  Think carefully about each one and whether or not you currently meet this criteria.  Put an “X” next to any item you need to work on.
  2. For each item you placed an “X” on, create a plan for improving skills related to that item. The internet is your friend here. If you’re not sure how to create Logins and Users, then open your favorite search engine and look around.  There will be people and tutorials that explain it.
  3. If you would like help with anything on this post, or with something else you’ve seen on the site, reach out to me here, and I’ll be glad to offer assistance.

3 Ways to Restore SQL Server Databases

This is likely the last in a series of three posts about backups and restores.  My aim with this series has been to give you an idea of the options available and a basic start on using those options. I’m not trying to go in-depth on the subject of backups and restores.

Today will be about getting you going on the concept of restoring databases in SQL Server.  I’m using a local install of SQL Server 2017 on my desktop PC to demonstrate these techniques.

Obtaining the StackOverflow Database

Before I dive into demonstrating the restore options, I want to talk a little bit about the set up. I’m using the StackOverflow2010 database.  Anonymized data dumps of the StackOverflow database are available here. This particular version of the database I’m using came from a page on Brent Ozar’s site.

I then used the below PowerShell code to take backups.  Between the Full and Diff backup I added one user to the Users table.  Between the Diff and Log backup I add two more users.

backup-dbadatabase -SqlInstance MySQLServer2017InstanceName -Database 'StackOverflow2010' -Path 'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010' -Type Full -FilePath dbname-backuptype-timestamp.bak -ReplaceInName -CompressBackup -Verify

backup-dbadatabase -SqlInstance MySQLServer2017InstanceName -Database 'StackOverflow2010' -Path 'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010\' -Type DIFF -FilePath dbname-backuptype-timestamp.bak -ReplaceInName -CompressBackup -Verify

backup-dbadatabase -SqlInstance MySQLServer2017InstanceName -Database 'StackOverflow2010' -Path 'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010' -Type Log -FilePath dbname-backuptype-timestamp.trn -ReplaceInName -CompressBackup -Verify

Below is the T-SQL I used to insert some rows.  That value for Age though!  Ah, to be 25 again!

 

INSERT INTO dbo.Users ([AboutMe], [Age], [CreationDate], [DisplayName], [DownVotes], [EmailHash], [LastAccessDate], [Location], [Reputation], [UpVotes], [Views], [WebsiteUrl], [AccountId])
VALUES
('I make SQL Server more stable, highly available and easier to manage', 25, GETDATE()-7, 'Lee Markum', 0, NULL, GETDATE(), 'Saint Louis, MO', 0, 1000000, 2000000, 'LeeMarkum.com', NULL)

--Took a differential backup here so I would have some changes to restore

INSERT INTO dbo.Users ([AboutMe], [Age], [CreationDate], [DisplayName], [DownVotes], [EmailHash], [LastAccessDate], [Location], [Reputation], [UpVotes], [Views], [WebsiteUrl], [AccountId])
VALUES
('I make T-SQL solutions that just work', 25, GETDATE()-7, 'T-SQLGuru', 0, NULL, GETDATE(), 'Saint Louis, MO', 0, 1000000, 2000000, NULL, NULL),
('I make SSIS solutions that just work', 25, GETDATE()-7, 'SSISGuru', 0, NULL, GETDATE(), 'Saint Louis, MO', 0, 1000000, 2000000, NULL, NULL)

--Took a log backup here

Using SSMS to Restore a Database

Just like for creating a backup, SQL Server Management Studio has menu options for restoring a database. Open your copy of SQL Server Management Studio and connect to a non-production or lab environment of some kind. You’re going to right click the database you want to restore and use the fly out menu to navigate to Tasks > Restore > Database.

 

Selecting the Database option from the fly-out menu above brings you to the below page. Notice in the following screen that SQL Server finds the applicable backup files for you. No in-depth knowledge of restore operations is needed in this case because the work is done for you. It has found the full, differential and log backups that I took earlier.  Each row represents a backup file.

If you only want to restore to the time represented by the differential backup, then uncheck the box next to the log backup.  SQL Server will then restore the full and differential backup, but not the log backup. You might want to do something like this if you know that the data in the database was corrupted or changed in an unexpected or undesired way immediately after the differential backup.  As a result, you restore the database to the point in time represented by the differential in order to restore the database to its last known good condition.

In the Destination section, SSMS fills in the name of the database that you selected earlier for restoring.  However, if you give the database a different name here, then you can restore the database and compare the restored database to the current database.  You might want to do this in order to attempt to repair data in the current database by getting data from the restore ddatabase. Please note the yellow banner that informs you that this process will take a tail log backup.  This is a preventative measure.  It captures the last portion of the transaction log called the tail of the log.  It allows for complete recovery.  Without this backup, if you restore this database, you could lose transactions.

 

One other option I want to point out on this screen is what the “Timeline” button is for. When clicked, you’ll arrive at a screen like the below.  This allows you to choose a point in time to restore to based on the available backups.  This point in time restore is only available for databases in the full and bulk-logged recovery model. For bulk-logged recovery model, certain rules apply as to when this option would be available.

If you select the radio button next to “Specific date and time” then you can either specify a certain date and time in the Date and Time boxes or you can also use the slider icon along the bottom.  There is also a Time Interval drop down that controls what you see in the colored timeline above the slider icon. Using this option is the same as using the WITH STOPAT command using T-SQL for the restore. For my demo, I have not used this option, but I want you to be aware that it is available. This Timeline feature is new in SQL Server 2012.

 

Once you have the General page looking the way you need it, click on the Files selection on the left to bring you to the page below. Here you have one option to work with and that is whether you want to relocate the database files to another folder. Checking this option allows you not only to relocate the files, but rename them as well.  You might want to do that if you’re restoring the database to a different name so that you don’t have two databases with different names, but the same file names. That might make it more difficult later to figure out which files belong to which database without running a query to figure it out.

Should You Use the WITH REPLACE Option?

Now click on the Options selection on the left.  You arrive at the below page. The option “overwrite the existing database (WITH REPLACE)” will bypass certain checks that would normally occur during the restore process.  As a result, you really would rarely use this option, if ever. This option will do what it sounds like and replace the target database with the database in the backup file.  If you mistakenly point this restore to database on a different server that isn’t the same database that is in the backup and use this WITH REPLACE option, then you will overwrite the other database on the other server. There is a large section in this page about caution using the WITH REPLACE option.

https://docs.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-2017

Here is where the option for taking the Tail-log backup is located.  You dshould leave this checked and note the location for where that backup will be written.  If it isn’t the location you would like, change it in the Backup file box.

There is also an important option under “Server connections.” If you leave this unchecked and there are current connections to the dtabase then the restore will fail.  A restore operation needs exclusive access to the database in order to perform a restore so other connections must be terminated first.  When this option is selected, SSMS will take care of that for you.

Once all the options you want are filled in, I would encourage you to click the Script option at the top so you can obtain the T-SQL equivalent for what SSMS is going to do. You can either click OK in the lower right of SSMS to execute the restore, or click Cancel and go to the T-SQL to review what will be done and then execute the T-SQL.

 

Now let’s turn our attention to using T-SQL for restoring a database.

Using T-SQL to Restore a Database

Below is the generated T-SQL for restoring the StackOverflow2010 database based on the available backup chain on my local SQL Server. I have added comments so you can better understand what each part is doing.  T-SQL syntax for performing a restore is, in most scenarios, not too difficult.  I am not showing things like file and filegroup restores or piecemeal restores.  These are more advanced scenarios.

USE [master]
/*This is the first part of the T-SQL generated when the "close existing connections" option is chosen in the GUI. This gives the session doing the restore the exclusive access needed.
*/
ALTER DATABASE [StackOverflow2010] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--This is the tail-log backup
BACKUP LOG [StackOverflow2010] TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010_LogBackup_2020-10-04_10-23-33.bak' WITH NOFORMAT, NOINIT,  NAME = N'StackOverflow2010_LogBackup_2020-10-04_10-23-33', NOSKIP, NOREWIND, NOUNLOAD,  NORECOVERY ,  STATS = 5

/*Here is the full backup.  Database restores need a place to start from and the full backup is that place.
*/
RESTORE DATABASE [StackOverflow2010] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010\StackOverflow2010-Full-202010030919.bak' WITH  FILE = 1,  NORECOVERY,  NOUNLOAD,  STATS = 5

--Here is the differential backup
RESTORE DATABASE [StackOverflow2010] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010\StackOverflow2010-Differential-202010030938.bak' WITH  FILE = 1,  NORECOVERY,  NOUNLOAD,  STATS = 5

--Her are the two log backups to restore
RESTORE LOG [StackOverflow2010] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010\StackOverflow2010-Log-202010030947.trn' WITH  FILE = 1,  NORECOVERY,  NOUNLOAD,  STATS = 5
RESTORE LOG [StackOverflow2010] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010_LogBackup_2020-10-04_09-20-23.bak' WITH  FILE = 1,  NOUNLOAD,  STATS = 5

/*This is the second part of the T-SQL generated when the "close existing connections" option is chosen in the GUI. This puts the database back to multi_user so it is ready to be used*/
ALTER DATABASE [StackOverflow2010] SET MULTI_USER

GO

 

Now let’s take a look at doing this with PowerShell

Using PowerShell to Restore a SQL Server Database

There are commands in the PowerShell on your local PC or server that will perform restores of SQL Server backups.  However, we will be discussing the PowerShell module called DBATools, which has to be installed before it can be used.

Please go to https://dbatools.io/download/ to see how to obtain and set up the module for use with this part of the blog post. I won’t be covering that here as the material is well documented on their site.

Once you have that, open PowerShell as an Administrator.  Type in the below code and hit F5.

Help Restore-dbadatabase -Detailed

This will give you a full description of the parameters and switches available in this command.  Numerous example code snippets will also be shown. From that help information I wrote the two examples that follow.  The first example will not perform the restore but instead writes to a .sql all the T-SQL needed to perform the command.  Strictly speaking, the -DatabaseName and value aren’t needed because the only backup files in that directory are for the StackOverflow2010 database. This option is useful so you can see what the command is going to do.

In the second example, the PowerShell will actually do the restore and then write it’s actions out to a text file. This is useful for having a history of what the command did.

In the third example, this will  use the folder structure from Ola Hallengren’s world famous maintenance solution. Notice the following switch:

-MaintenanceSolutionBackup

There are also switches for maxtransfersize, buffercount, and blocksize.  These can all be experimented with for your databases to find an optimal combination that restores the database as fast as possible. Additionally, there is a -RestoreTime option that is the equivalent of the WITH STOPAT syntax in T-SQL and the TimeLine function in the SSMS GUI.

<#This will not perform the restore, but will instead create a .sql file of the necessary T-SQL to do the requested restore.
#>
Restore-DbaDatabase -SqlInstance MYPC\Kronos2017 -DatabaseName StackOverflow2010 -Path 'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010' -WithReplace -OutputScriptOnly | Out-File 'C:\DBAToolsRestoreScripts\RestoreStackOverFlow2010.sql' 

<#This will do the restore and create a text file showing what the PowerShell command actually did
#>
Restore-DbaDatabase -SqlInstance MYPC\Kronos2017 -DatabaseName StackOverflow2010 -Path 'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010' -WithReplace | Out-File 'C:\DBAToolsRestoreScripts\RestoreActionsStackOverFlow2010.txt' 

<# This will do the restore based on Ola Hallengren's directory structure from his world famous maintenance solution.  Notice the switch -MaintenanceSolutionBackup
#>
Restore-DbaDatabase -SqlInstance MYPC\Kronos2017 -Path 'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010' -MaintenanceSolutionBackup -WithReplace -OutputScriptOnly | Out-File 'C:\DBAToolsRestoreScripts\RestoreStackOverFlow2010.sql' 

Next Steps to Take

  1. Download and install DBATools.  It’s useful for a lot more than handling SQL Server restore scenarios!
  2. If you’re not familiar with PowerShell, you need to learn it, if for no other reason than the options that DBATools provides you for working with SQL Server.
  3. Connect to a test server and try out each method. Get some experience with these methods so you know which one you like the most and so you’re not trying to figure out how you want to perform a restore when you actually have to do it for real.

5 Ways to Make SQL Server Backups

Last time we discussed 5 backup types for SQL Server.  Now I want to introduce you to five ways to make backups in SQL Server. I can’t possibly explore all the options available with each of these six methods. There is a lot to cover for even a “simple” topic like backups.

Method 1: Using the SSMS GUI to Make a Back up

 

For those readers who like the SSMS GUI, there is good news.  SQL Server Management Studio offers a fairly straightforward method for backing up a database. Once you connect to the SQL Server instance containing the database you want to back up, left click on the “+” sign next to the Databases folder.  Then right click the name of the database you want to backup, choose Tasks, then choose the Backup option in the fly out menu.

That brings you to the General Backup Menu page in SSMS.  In this menu you can access a number of settings related to the backup that will be generated.

With the “Backup type” drop down you can control whether this will take a Full, Differential or Log backup.

The “Backup component” section can be adjusted to take either a backup of files and filegroups or the default selection of “Database.”

In the Destination section you can backup to the default of “Disk” or choose “URL” from the drop down to make a backup to Azure as the target. When the destination of Disk is left you will be supplied with the destination of the backup and a filename for the backup.  This directory will be the default backup directory selected during the SQL Server installation.  If this is not where you want the backup, simply click “Remove” then click “Add” to navigate to the location you want to use.  The “Add” menu does accept share paths.

The Media Options selection on the “Select a Page” allows you to choose options for things like whether you want to append this backup to the same media set or start over with a new one.

The media options seem to me to be from an earlier day when backups were written to physical tapes.  Those tapes then had to be rotated from time to time.  It’s not a best practice to append backups to the media set because you’re adding backup files into a single media set.  If something happens to the media set and it is unusable, then the backups are not accessible.

In the Reliability section, you should check the options for “Verify backup when finished” and “Perform checksum before writing to media.” Thes options will cause your backup to take longer to complete, but they do help with validating the integrity of the backup at the time it was written.

The Backup Options are in the “Select a page” menu has what I think is one very important feature to note.

On this page there is an option related to backup compression.  Back in older versions of SQL Server, like 2005 and 2008 this was an Enterprise Edition only feature.  As of SQL Server 2008R2 it is available in Standard Edition.  To make using this compression the default for all of your backups, simply run the code below on your SQL Server.  Then, when you get to this option in the SSMS GUI, just leave it set to “Use the default server setting.”  You’ll want the space savings that compression offers.  Why use more space on your separate storage for backups than is necessary? I mean, you are storing your backups somewhere other than on the SQL Server, right?!

EXEC sys.sp_configure N'backup compression default', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO

Once you work through these meu options, simply click “Ok” and SQL Server will make the backup for you.  You can also click on the “Script” option at the top middle of the wizard to have SQL Server show you the T-SQL it is about to run.  You could save this as an example script to review later.

Method 2: Using T-SQL To Make a Backup

T-SQL is a tried and true method for backing up databases.  You have more options available when backing up with T-SQL versus the GUI.  Most of those options are going to be more advanced options. A very basic example of the backup command that produces a full backup is below. That is followed by examples for a differential backup and a log backup.

BACKUP DATABASE [MyDB] TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL14\MSSQL\Backup\MyDB_Full.bak'

BACKUP DATABASE [MyDB] TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL14\MSSQL\Backup\MyDB_Differntial.bak' WITH DIFFERENTIAL

BACKUP LOG [MyDB] TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL14\MSSQL\Backup\MyDB_log.trn'

Buffer Count and maxtransfersize are two options worth noting. You can experiment with these T-SQL options to take backups faster. The buffer count value conrols how many I/O buffers are used for processing the backup and the maxtransfersize controls how much data is moved at any one time.

Below I’ve provided three examples from my testing on my home lab PC. The initial buffercount and maxtransfersize data was captured by turning on trace flags 3605 and 3213 then looking in the error log after the first backup was taken.  After that I simply experimented with values.  Be aware that increasing the buffer count too much can cause an out of memory error.

As you can see, the initial throughput was 219.412 mb/sec and the elapsed time for that part was 39 seconds. This was using SQL Server defaults.

Increasing the buffer count to 8 increased the throughput to 258.653 mb/sec and the elapsed time dropped about 6 seconds. Combining the second change with a maxtransfersize of 4MB increased the throughput to 270.095 and pushed the time down another 1.4 seconds. I shaved 8 seconds off the backup time.  This was for a small database of about 14 GB.  For larger databases the increased throughput could represent a significant time savings.

BACKUP DATABASE [StackOverflow2010] TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010\StackOverflow2010_backup_2020_09_20_180836_9111962.bak' WITH NOFORMAT, INIT,  NAME = N'StackOverflow2010-Full Database Backup', 
SKIP, NOREWIND, NOUNLOAD,  STATS = 10, CHECKSUM
GO
/*
buffercount = 4 and maxtransfersize = 1024kb
no options
Processed 1096456 pages for database 'StackOverflow2010', file 'StackOverflow2010' on file 1.
100 percent processed.
Processed 2 pages for database 'StackOverflow2010', file 'StackOverflow2010_log' on file 1.
BACKUP DATABASE successfully processed 1096458 pages in 39.041 seconds (219.412 MB/sec).
The backup set on file 1 is valid.
*/

BACKUP DATABASE [StackOverflow2010] TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010\StackOverflow2010_backup_2020_09_20_180836_9111962.bak' WITH NOFORMAT, INIT,  NAME = N'StackOverflow2010-Full Database Backup', 
SKIP, NOREWIND, NOUNLOAD,  STATS = 10, CHECKSUM, BUFFERCOUNT = 8
/*
Buffer Count = 8
Processed 1096456 pages for database 'StackOverflow2010', file 'StackOverflow2010' on file 1.
100 percent processed.
Processed 2 pages for database 'StackOverflow2010', file 'StackOverflow2010_log' on file 1.
BACKUP DATABASE successfully processed 1096458 pages in 33.118 seconds (258.653 MB/sec).
The backup set on file 1 is valid.
*/

BACKUP DATABASE [StackOverflow2010] TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.KRONOS2017\MSSQL\Backup\StackOverflow2010\StackOverflow2010_backup_2020_09_20_180836_9111962.bak' WITH NOFORMAT, INIT,  NAME = N'StackOverflow2010-Full Database Backup', 
SKIP, NOREWIND, NOUNLOAD,  STATS = 10, CHECKSUM, BUFFERCOUNT = 8, maxtransfersize = 4194304

/*
Buffercount = 8 and maxtransfersize = 4MB
Processed 1096456 pages for database 'StackOverflow2010', file 'StackOverflow2010' on file 1.
100 percent processed.
Processed 2 pages for database 'StackOverflow2010', file 'StackOverflow2010_log' on file 1.
BACKUP DATABASE successfully processed 1096458 pages in 31.715 seconds (270.095 MB/sec).
The backup set on file 1 is valid.
*/

 

Method 3: Using Powershell to Make a Backup

 

If you’re not using PowerShell with your SQL Servers, you should be.  If you’re not using the DBATools module with your SQL Servers, get it now. PowerShell can do fantastic, wonderful things and DBATools can do powerful, amazing things for you with respect to all things SQL Server. Below is a simple example of using the DBATools command Backup-DbaDatabase to make a full backup.  The command has a full range of options available., including backing up all the databases on a SQL Server when you don’t pass the -Database parameter. You should check into it right away.

Backup-DbaDatabase -SqlInstance MySQLServer -Database Stackoverflow2010 -path 'C:\Program Files\Microsoft SQL Server\MSSQL14\MSSQL\Backup'

 

Method 4: Using Maintenance Plans to Make a Backup

 

Because this post is already running long and there are a lot of other places that show how to use maintenance plans, I’m not going to step through how to do this here. You can go here and here to see how to use maintenance plans.  Also Jonathan Kehayias has a Pluralsight course on using them.

I am going to give you some quick thoughts on using maintenance plans though. First, Maintenance Plans are another GUI method to setting up backups.  In that respect, they are an easy point and click method to handle taking backups and handling backup retention, which we haven’t even talked about. Secondly, because of the nature of this method, which allows you to pick Backups as an option for a plan and then steps you through each part of a workflow wizard, Maintenance Plans can be a common approach for IT professionals coming from the SysAdmin side of things. No need to know or understand the options presented in the SSMS Backup wizard, for example.

Some downsides exist in backups inside maintenance plans prior to SQL Server 2016. Namely, the below options don’t exist.

– Perform checksum
– Continue on error
– Block size
– Max transfer size

Method 5: Using Ola Hallengren’s Maintenance Solution to Make A Backup

 

You can get help with Ola’s scripts here. Ola’s scripts are known and used world wide by DBAs.  They just work.  When you go to his page, you’ll download the file maintenancesolution.sql.  That file contains not only the backup routine but routines for CHECKDB and index maintenance.  You can download each components scripts individually as well. On his support page for the backup script, he explains all the available options and provides a laundry list of real world examples for how to set up the scripts for various scenarios.

Ola has options for the buffer count and maxtransfersize I demonstrated earlier.  He has options for using his scripts with AlwaysOn Availability Groups and he has options for backup retention. His scripts even work with third party vendor applications like LiteSpeed and Red Gate SQL Backup Pro.

What to Do Next:

  1. Review your current backup strategy and look for servers that aren’t being backed up at all.
  2. If you are a SysAdmin or an “Accidental DBA”, look at those links about setting up maintenance plans and get busy backing up your servers.
  3. If you didn’t know about DBATools,then stop what you’re doing and go to their web page.

5 Types of SQL Server Backups

One of the foundational responsibilities of a DBA is making sure that backups are available.  SQL Server has several foundational types of backups that can be made. Before I dive into that though, I want to ask a question that seems to have a fairly obvious answer.

Why take backups?

  1. You want to be able to recover from data corruption or mistakes made when people make changes directly to the data – like when they write and run a script in SSMS, outside of an application that’s using a set of tested stored procedures.
  2. You want to be able to refresh you non-prod environments so developers have data that looks like prod  to develop against.
  3. You want to have backups so you can test whether you can restore and how long it will take
  4. You want backups as they are often an essential part of the migration process from one SQL Server to another – usually newer SQL Server, or to Azure.

SQL Server Full Backups

What does a full backup accomplish?  A full backup, creates a backup of the entire database. It is all-inclusive, containing the entire database structure and all the data.  When a full backup starts, the Log Sequence Number is recorded and when the full backup completes, the Log Sequence Number is recorded.  This Log Sequence Number is the mechanism used by SQL Server to know what order INSERTS, UPDATES or DELETES occurred in.  As such, having the beginning and ending Log Sequence number recorded as part of the full backup allows for a transactionally consistent backup because the full backup is aware of the changes that took place while the backup was being made.  This allows for recovery of those transactions during the restore process. This full backup serves as the base backup, or starting point for all differential and log backups after it.  Each time a new full backup is taken, a new base backup point is created.

SQL Server Differential Backups

What does a differential backup do for you?  A differential backup works off the concept of a differential bitmap.  SQL Server is composed of eight kilobyte pages. These pages are collected in groups of eight called “Extents.” There is a bitmap that is used to mark any Extents that have experienced data changes since the last full backup. When a differential backup is executed, it is this bitmap that determines what data is backed up.

Based on the size and rate of change in a database, differential backups are often going to complete faster than a full backup.  Additionally, the differential backups will be smaller in size since only changed extents are backed up, rather than the entire database.

When the full recovery model is used, the power of the differential can be very important.  The differential backup reduces the number of log backups that have to be restored. For example, if there is a full backup taken on Sunday night, and transaction logs every 15 minutes after that, when a DBA needs to restore the database to Thursday at 5:53 AM, she needs to construct a restore process based on the Full backup and every transaction log since Sunday evening!  That’s a lot of transaction logs to have to include.  With a daily differential occurring at 5 AM, the DBA now only needs to restore the full backup from Sunday evening, the one differential that was created at 5 AM on Thursday, and only the transaction log backups that occurred after 5 AM Thursday. Being able to skip over using all those log backups is powerful.

This makes for much simpler script creation and readability, and can save a lot of time if the DBA is trying to write this script manually.  You should have an automated process to create the backup script, but some DBAs don’t have that set up yet. We’ll talk about automating the backups script creation  later in the series.

SQL Server File and FileGroup Backups

What are File and FileGroup backups? Well to start with, this is a more advanced topic than these other backup types. As such, it is less likely that you will need this type of backup. However, knowing what your options are is always a good idea.

File and FileGroup backups allow a more granular backup, and by extension, a more granular restore process. It does what it sounds like.  A file or filegroup backup backs up an individual file or a collection of files contained in a filegroup. This allows for restoring a small part of a database to fix a problem rather than having to restore the entire database. This option, however, does introduce complexity and, in my opinion, is really only useful for large databases, particularly in the range of 500 GB or more.

These file and filegroup backup types can be used when a larger database has been divided into multiple files.  For example, a large database containing sales information might be divided into various Sales files, perhaps by year, or even by month if there are a high volume of sales recorded in the database.  These files are then aggregated into FileGroups. See below for an example of creating files and filegroups in a database. This example was taken from the  MS docs page here.

USE master;
GO
-- Create the database with the default data
-- filegroup, filestream filegroup and a log file. Specify the
-- growth increment and the max size for the
-- primary data file.
CREATE DATABASE MyDB
ON PRIMARY
  ( NAME='MyDB_Primary',
    FILENAME=
       'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\data\MyDB_Prm.mdf',
    SIZE=4MB,
    MAXSIZE=10MB,
    FILEGROWTH=1MB),

--Here is where a separate file is created and assigned to a FileGroup, which is little more than a container.
FILEGROUP MyDB_FG1
  ( NAME = 'MyDB_FG1_Dat1',
    FILENAME =
       'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\data\MyDB_FG1_1.ndf',
    SIZE = 1MB,
    MAXSIZE=10MB,
    FILEGROWTH=1MB),

--Here is where another separate file is created and assigned to a FileGroup.
  ( NAME = 'MyDB_FG1_Dat2',
    FILENAME =
       'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\data\MyDB_FG1_2.ndf',
    SIZE = 1MB,
    MAXSIZE=10MB,
    FILEGROWTH=1MB)
LOG ON
  ( NAME='MyDB_log',
    FILENAME =
       'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\data\MyDB.ldf',
    SIZE=1MB,
    MAXSIZE=10MB,
    FILEGROWTH=1MB);
GO
ALTER DATABASE MyDB 
  MODIFY FILEGROUP MyDB_FG1 DEFAULT;
GO

-- Create a table in the user-defined filegroup.
USE MyDB;
CREATE TABLE MyTable
  ( cola int PRIMARY KEY,
    colb char(8) )
ON MyDB_FG1;
GO

SQL Server Transaction Log Backups

What is a transaction log backup? A transaction log backup will take a backup of SQL Server’s transaction log so that data changes stored there can be recovered during the restore process.  Again the Log Sequence Number concept mentioned earlier is key.  Because transactions occur in a certain order, the log backups contain that order of transactions.  Transaction log backups must be restored in order.  If you try to restore a sequence of log backups in the wrong order, SQL Server will generate an error.

Having these log backups allows you to do what is called a point in time restore.  Having the option for a point in time restore can be critical for a business. Let’s suppose someone is making changes directly to one or more tables.  If a mistake is made and an unexpected data change occurs, point in time restore will allow you as the DBA to recover the data up to the moment just before the erroneous change was made.

SQL Server Copy Only Backups

What are Copy-only backups?  Copy only backups are backups that do not affect or track the Log Sequence Number information.  Why would you use this? Well, let’s suppose that you are already taking full, differential and log backups.  You are asked to provide a backup file of a database to another department or perhaps just a single developer who is working on a project. That Developer, hopefully, doesn’t have access to the backup directory for your backup processes.  Rather than you trying to copy a set of backups to a share or other location that the Developer does have access to, you could simply create a Copy Only full backup that is written to a shared location.  The Developer can then use that backup to restore locally to her machine, and you receive the benefit of not changing the base backup for your backup chain.

What to Do Next

  1. Examine your environment to see if you are leveraging the “Power of the Diff” by taking differential backups to help simplify your recovery process.
  2. Consider the size of your databases and determine if you have a situation that might benefit from having a database with multiple files and filegroups.

How Do You Find Good SQL Server Training Resources?

What process can you use to find SQL Server training that will be valuable? After all, not everything on the internet can or should be trusted.  If you want training on something in this constantly changing world of technology, how do you locate that training?  How do you find information that is worth spending your time on?  How much of it costs something?  How much of it is free and is the free stuff any good?

I live in the Microsoft world in general and specifically in the SQL Server universe so that is where I am going to focus.  But, to be clear, this process, and the methods I am going to talk about, will be relevant even if you are a C# Developer or some other kind of IT knowledge worker that has little or nothing to do with databases. I would be surprised if Linux and other open source software didn’t have some equivalencies to what I am going to discuss later on.

Let’s suppose you’ve been sitting next to the SQL Server for awhile and you’ve fixed a few things from time to time.  Congratulations!  You are now what is called an “Accidental DBA.”  You’ve fallen, quite by accident, into managing SQL Server in some capacity.  You’re sensing, though, that there’s a lot more that needs to happen and you have no idea where to start to find information.  After all, when you Google “SQL Server” you get back about a million hits and you don’t know who is a reliable source of information or what you should focus on first.

  • Microsoft MVPs

Have you heard of Microsoft’s Most Valuable Professional program?  If not, this is a good entry point for finding quality content. A Microsoft MVP is a person who has invested significant time into making the Microsoft community a better place.  They do this through three main avenues.  First MVPs may make significant contriubtions to coding projects.  Second, they certainly spend time helping others.  This usually comes from answering questions at places like MSDN, StackExchange.com or SQLServerCentral.com. Third, they create content.  This comes from doing things like blogging, writing articles, and publishing written materials.

So, what does this have to do with training? I’m glad you asked. Remember how we want to know how to sift through all the hits on the internet when you type in something like “SQL Server training”? You want to find the good stuff, right? Well, since you want to learn about something in the Microsoft world, why not find out who the MVPs are and learn from them?  Many of them have their own websites where they create content. Some of them will have special training that they have created on a variety of subjects.  The blog content is going to be free.  Usually you’ll need to fork over some money for the special training they have made.

Here is how to find Microsoft MVPs.  Go here and click the link at the top of the page for “Find an MVP.” For the SQL Server category, select Data Platform from the “Award Category” drop down. If you want to see MVPs in your area, hit the “Region” drop down and select your region to filter the results. From there, click on the name of an MVP and you will be directed to a profile page that will provide a summary of that person.

The summary page for an MVP will show where they have presented and what the presentation title was.  The profile summary will often have links to the person’s blogging locations as well, their Twitter account, and even books they have written. Want to see if someone you follow is an MVP?  Type the person’s name or part of their name into the Keyword box and click “Search”. Beyond the information on the MVP site for a particular person, sharpen your internet search skills and type in the person’s name.  See what you can find!

  • Paid Video Training

  • Pluralsight – In the interest of fairness in terms of the comparison to CBTNuggets, you should know that I’ve had a Pluralsight subscription of my own for years.  I have only in the last year or so learned about CBTNuggets.

On Pluralsight you will see courses from SQL Server people like Paul Randal, Kimberly Tripp, Erin Stellato and others from SQLSKills.com. People like Gail Shaw, Pinal Dave, and Mike MCKeown also have SQL Server courses on Pluralsight.  The platform has reasonably priced monthly and yearly plans. Personal plans on Pluralsight are $29 a month.  You can download exercise files that allow you to work through the content as you watch the presenter or later on your own. The platform also has skills test for a variety of subjects.

A couple of my favorite features  are called Paths and Channels.  Paths are pre-built collections of content that Pluralsight provides to you for learning a topic.  You can subscribe to Paths and you can combine a pre-built path with other content you’re interested in via the creation of a Channel.  Let’s say you’re interested in a group of courses that aren’t part of a path.  What do you do?  Well, don’t fret. That’s what Channels are for.  You can build you own custom path by adding courses to a Channel that you name.  You can also add a pre-built Path from Pluralsight to your custom channel.

Pluralsight also tracks weekly minutes spent watching videos so you can see how much time you’re spending on training and there is a history page so you can see what courses you’ve watched and how much of that course has been viewed.

  • CBTNuggets – At $59 per month, this platform is ore expensive than Plauralsight.  However, CBTNuggets has a few features that Pluralsight doesn’t.

The CBTNuggets platform offers virtual labs that can be spun up from directly inside a course. Additionally, there are IT Certification practice exams from Kaplan as part of the monthly subscription fee.

They also have accountability coaches.  These coaches help subscribers stay on track with their learning goals and they provide additional resources for learning the material as well as learning strategies.

The SQL Server  training on this platform is geared toward the Microsoft Certifications and are taught by people I am less familiar with.  Most of these certifications retire on Jan 31, 2021.  It doesn’t mean there is no value in taking these courses after that date, as I’m sure you would learn a lot from the courses, assuming CBTNuggets keeps them up after the certification expiration.  I certainly think these course could be helpful for someone trying to earn a Microsoft certification before Jan 31, 2021.

 

  • Free Video Learning

There is a growing body of great, free training on the internet.  When looking for this type of learning, search for people who are Microsoft MVP’s in the area you want to train for.

  • Search YouTube for MVPs or well known people who have advanced knowledge of a topic you’re interested in and subscribe to their channels.  YouTube also has playlists of pre-aggregated content on a particular topic.  You can search for playlists by topic like “SQL Server DBA Playlist” and find many playlists to save and watch later. Below shows a playlist for Wise Owl Training on SQL Server Reporting Services. Notice the icon in the lower left corner?  The three dashes and the + sign allow you to save this playlist to your YouTube page.  Then the playlist will appear on the main YouTube home screen on the left.

Here is a sample from my own YouTube playlists. I am not currently watching all of these, but they are playlists I definitely intend to watch.  When I need training on a topic, these playlists provide a handy way for me to find something quickly.

  • Find companies that offer free video training on topics of interest. For example, PragmaticWorks has free videos on a wide range of SQL Server topics. RedGate has a lot of free stuff on SQL Server and Dev-Ops for the database.
  • Find websites of individuals who blog about topics of interest. Besides the blog, some of those people are likely to make videos that are free to watch. This is true of Brent Ozar and Kendra Little, for example.

 

  • Free Online Conferences

Free online conferences are popping up like crazy now that in-person events are being shelved because of Covid.  More and more vendors are assembling virtual conferences, many of them free.

  • EightKB – This is a brand new SQL Server internals conference.  So far they have hosted one virtual event, and I attended.  The content was amazing.
  • Groupby.org – This was initially started by Brent Ozar but is now being headed up by Blythe Morrow.  This is event is held quarterly and has excellent speakers from around the world.
  • “New Stars of Data” – This is a brand new platform launched in 2020 that provides a place for up and coming data experts to speak.

 

  • Paid Conferences

  • DevIntersection – This is a yearly conference hosted in Las Vegas.  It is a broad conference, covering a wide variety of technology.  There is a SQL Server specific track called SQLIntersection. Early bird registration for this event runs anywhere from $1,700 to just over $3,000 depending on how many workshops you attend.
  • PASS Summit – The virtual event costs around $1,000 this year.  They are hoping to be back to in-person events on 2021.
  • SQLBits – This is a data platform conference focused on the SQL Server platform that is hosted in the UK.  Current prices and currency exchanges place the cost of a 2 day conference and 3 workshops at just over $,1000 US dollars.  It is a virtual conference this year.
  • DataGrillen – This in-person conference was cancelled for 2020.  It is hosted in Germany.

 

  • Blogs/Websites/People

  • Brent Ozar: Microsoft Certified Master for SQL Server who focuses on making SQL Server faster and more reliable (i.e. he does performance tuning)
  • Kendra Little – Microsoft Certified Master for SQL Server and now also blogs about DevOps for the Database for RedGate Software.
  • Paul Randal and friends – Paul Randal and Kimberly Tripp worked at Microsoft and are now married.  The site SQLSkills.com was founded by Kimberly and she and Paul run that site and company.
  • Itzik Ben-Gan: Itzik is a co-founder of SolidQ, a company that provides training on leveraging the T-SQL language to solve query problems.  If you want to learn T-SQL inside and out, look up this company and find resources from Itzik.
  • DBATools – Chrissy LeMaire and others have built numerous PowerShell commands into a powerful module that can be used to manage most aspects of SQL Server.
  • SQLServerCentral – I was first introduced to this site because of the forums where a lot of well-known SQL Server experts hang out and answer questions.  But, they also have a lot of training series articles on a wide variety of topics that they call their “Stairway Series”.
  • Microsoft Learn – This is Microsoft’s newest iteration of it’s free training platform. It provides a lot of information on the newest Microsoft certifications as well as free training paths to help users earn a certification. There are a number of data related paths, primarily connected to learning Azure.

Reader, we haven’t even talked about books, classes that might be held at a training center in your local area, or SQLSaturdays.  There is a wide range of means for you to obtain training and help on the SQL Server platform.

  • What to do next

  1. Find at least one sub-point under each of the above main bullet points and investigate that item thoroughly.  Look up MVPs and start following one of their blogs. Investigate YouTube and save some playlists. Check out Microsoft Learn. Pick one thing from each main category above.
  2. Use those selected items to build a training plan for yourself.
  3. Put that training plan somewhere so that you will see it, everyday. Mine is on the white board behind me in my home office.

 

 

Azure SQL Boot Camp Day 3 Takeaways

Hello reader!  Here we are with the much anticipated post for day 3 of the recent Azure SQL Boot Camp. Here are the previous posts for days one and two .

If you want to get started with Azure  SQL, the boot camp is a great way to do it.  You’ll get Azure experts like Anna Hoffman and Bob Ward, who is also a long time SQL Server expert, teaching you how to leverage the cloud for SQL Server. On day three, Anna does a couple of demos on the subject of HA that demonstrate the capabilities of the Azure platform.  Other days have demos of other concepts as well.

Not only will you learn specifically about SQL Server in Azure, but this series is going to teach you other foundational concepts about Azure that are applicable no matter what you’re trying to do in Microsoft’s cloud. Things like cloud networking and the security aspect that needs to go into that networking, as well as how to give people access to resources in a secure way, are relevant for every part of Azure. With that, let’s dig into what day 3 had to offer.

Day 3 of the Azure SQL Boot Camp was all about availability.  When done right, availability solutions keep your environment up and running when things don’t go right. Here are the key takeaways for Day 3 regarding high availability:

  • Azure has you covered in terms of backup/restore.
  1. A full backup is taken weekly.
  2. A differential backup is taken ever 12 hours.
  3. Log Backups are taken every 5 to 10 minutes.
  4. Backups are stored on Read Access Geo-Redundant Storage, which means there are multiple copies of backups in differing locations.  This protects you from losing the backups.
  5. Point in time restore is available.
  6. Backup integrity checks are peformed and there is even automated, random testing of those backups via automatically restoring some of them from time to time.
  7. Backup retention is by default at 7 days.  You can go up to 35 days or even use the Long Term Retention service and keep backups for as long as 10 years.
  8. With Managed Instance a copy only backup option is available.
  9. On premises backups can be used to restore to a Managed Instance as part of a migration strategy.

Let’s be honest, how many of you have a backup strategy that is this solid? Some of you have databases that are in full recovery model with no log backups happening. Yikes! Don’t believe me? Check into your backup history information in msdb with a little T-SQL and you can verify for yourself whether your environment is up to snuff in this regard.

How many of you are writing backups to the same location as the data? And, the big question is this: How many of you are testing whether you can use your backups to perform a restore? Remember, just because you have backups doesn’t mean you can restore.

If you don’t have these sorts of things in place, you might be doing a lot of mopping up after a disastrous situation. “Clean up on aisle 4!”

  • Azure has you covered when it comes to High Availability
  1. In the general purpose tier, Azure customers get a service that behaves like a SQL Server Failover Cluster Instance.
  2. Auto failover is possible and is handled by SQL Server and the Azure Service fabric.
  3. There is local SSD and local Tempdb with data files in premium storage.
  4. Backup files are geo-redundant.
  5. In the Business critical tier, Azure customers get Availability Groups behind the scenes – set up and configured for you automatically. With this service, you get 3 secondaries, only one of which has to harden transactions in order for the primary to commit transactions, and one replica for read only routing.
  6. In the hyperscale tier, you get snapshot backups taken by Azure, up to 4 secondaries and they can all be readable, as well as redundant data and log files through the log service and long term storage on Azure Standard Storage.
  7. Services like Zone Redundant Configuration, or Availability Zones, provide additional HA services for Azure SQL DB, but not in all regions.  This method of HA is currently not available for Azure Managed Instance.
  8. Geo-replication and auto-failover groups are a central piece to HA in Azure. Geo-replication has multiple replicas and supports read scale out. With this service offering, you do have to update connection strings after a manual failover is initiated.  It is asynchronous but you can use a system stored procedure to force synchronous commit prior to a failover. Geo-replication does not allow for failing over multiple databases together, and is available only for Azure SQL DB. Auto-failover groups can failover multiple databases at once with no changes to the application connection string.  It supports read scale out and is available only in Managed Instance.

Again, let’s do a gut check. How many of you are running important or business critical SQL Servers on stand alone servers and your only real option for recovery if the machine has an issue is to create a new SQL Server and restore all your backups? In this scenario, that important or business critical SQL Server doesn’t have a second copy via log shipping or some sort of replication, mirroring or an Availability Group.

Go on…. think about it.  List your important and critical business servers in a Word doc. Now examine the list and ask yourself what would happen if any of those servers died and couldn’t be recovered.  Would some part of your business stop while you tried to build a new SQL Server and restore? If so, I think you just found an urgent action item to put at the top of your to do list.  As you determine your solution, think about whether some form of SQL Server in Azure can give you what you need.

This is an important feature that is on by default in Azure.  It is available in SQL Server 2019 on-premises, but it is not on by default. It uses a persisted version store to house old data rows.  Those old data rows, and the most recent checkpoint, are used for a faster rollback.  This addresses the problem of a long rollback from a long running transaction that was killed.

Well, that is the summary for Day 3 of the Azure SQL Boot Camp. There is more that was discussed, but remember, I am only trying to give you a summary of key takeaways. Enjoy as you dig into SQL Server in the Azure cloud!

Azure SQL Boot Camp Day 2 Key Takeaways

Hello dear reader.  This is the second of a four part series on a recent online event hosted by Microsoft on their Microsoft Developer page over on YouTube.  From August 17th to August 20th Ann Hoffman and Bob Ward hosted a live boot camp for Azure SQL.  This post provides you with key takeaways from day 2 of that event.  The topic title for Day 2 was Azure security and performance.  Below are my takeaways. If you’re looking for Day 1 takeaways, look here.

I. Four methods discussed for handling network security in Azure for Azure SQL database.

    • The setting “Allow Access to Azure Services.” This setting allows any Azure resource to communicate with other Azure resources. So, this allows wide open communication between all your Azure resources. It is not recommended to leave this enabled.
    • Firewall Rules : This is what it sounds like – a firewall service hosted by Azure that allows you to build rules about access within and to and from Azure services, including traffic related to on-premises resources.
    • Virtual Network Rules : These are rules are a feature of the Azure firewall.  They are applied at the server level and not the database level.
    • Private Link : This is the creation of a private endpoint for network communication.  This is the most secure method.

II. Understanding RBAC is important.

RBAC stands for Role Based Access Control and is a means to provide granular controls in your Azure environment.  This feature isn’t just about SQL.  RBAC is applicable to your total Azure environment. This method of security involves assigning a role, which is just a named collection of permissions, to a security principal and making that assignment at a certain scope.

Security Principals

A security principal can be a user, group, service principal or a managed identity.  A user is an individual account with access in Azure Active Directory. The “Group” service principal is the same concept as a Windows AD group. It is a collection of users created in azure Active Directory. A Service Principal can be thought of as a user account for an application.  A Managed Identity is an identity managed by Azure that provides access to Azure resources, like Azure Key Vault, for example. A managed identity might be used to access Azure Key Vault to retrieve other secrets that are needed. Managed identities are a feature of Azure Active Directory and are included in subscriptions to Azure AD.

Remember, I said that RBAC is about assigning collections of permissions, called Roles, to security principals and making that assignment at a certain scope. Well, we’ve talked about security principals So let’s discuss roles.

RBAC Roles

There are four categories of roles that are applied to various resource types in Azure.  Those roles are:

  1. Owner – Has full access to all resources within a subscription.  Service principles in this role can also delegate access to other people.
  2. Contributor – This role allows a service principle to create and manage access to resources, but can’t grant access to others.
  3. Reader – This role only allows view access.
  4. User Access Administrator – Manages user access to resources.

These categories of roles appear in various forms and with various names within categories of resources like Computer, Networking, Storage, Integration, Security, etc.

Scopes Within Azure

A scope is a set of resources that access applies to. Scope has a hierarchy with parent-child inheritance. Grant access at the very top, and you’ve granted that access to everything below it.T he hierarchy is Management Group > Subscriptions > Resource Group > Resources.

What are some examples of things RBAC can be used for?

  • Allow a person to manage virtual networks but not VMs.
  • Segment access for Development DBAs just to non-prod databases. They can be in a group with the Contributor role so they can create and manage databases within a subscription that hosts only non-prod databases.
  • Allow a person to view endpoints, but not change them in any way.

III. Authentication to Azure SQL

  • Mixed mode authentication to SQL is forced.
  • SQL auth login is required during deployment and is called “server admin.” This account is a server level principal and is effectively in the “sysadmin” role for the server and databases.
  • If you need Windows authentication then you need to use Azure Active Directory.
  • There are some syntax differences with the CREATE LOGIN scripting for managed instance and Azure SQL Database. This is most notable when Azure AD authentication is involved.
  • There are a couple of less privileged database roles that can be utilized to limit the need for using the server admin SQL auth login. LoginManager is a database level role in the master database of the logical server. People in this role can create logins for the database server. The DBManager role is also located in the master of the logical server. This role can create and delete databases on the database server.

IV. Azure SQL Performance Capabilities

There is a lot that could be said about performance for Azure SQL. I am only giving you some key takeaways.

  1. Large scale capacity in Azure is absolutely available.  You get up to 128 vCores, 4 TB of memory and 4 TB’s of space for a database in Azure SQL. In Hyperscale you have a 100TB max database size.
  2. TempDB is on local SSD and the MIXED_PAGE_ALLOCATION setting is off.
  3. Only full recovery is supported so minimal logging in bulk operations is not available.
  4. MAXDOP is controllable at the database level.
  5. Optimize for ad hoc workloads, a great feature for managing plan cache bloat, is supported for SQL Managed Instance but not for SQL Database.

V. Azure SQL Monitoring

There are a lot of options for monitoring in Azure.  The portal provides access to a lot of different options.  You get things like Azure Monitor Metrics, alerts and logs that can be reviewed.  Performance overview and query performance insights in the portal are provided via Query Store, which is on by default.

Extended events is available in Azure Managed Instance and Azure SQL DB. The one thing to be aware of is that you don’t have access to the underlying file system for Azure SQL DB so the only way to have a file target for an extended events session is to use Azure Blob storage.

Dynamic Management Views are available in Azure Managed Instance and SQL DB. For managed instance all SQL Servers DMVs are available.  For Azure SQL DB a common subset of DMVs are on hand.

Remember that for Managed Instance there is no access to the underlying operating system so things like perfmon are not available.  Despite that, you do have access to the perfmon counters via sys.dm_os_performance_counters.

There are some Azure specific DMVs.  Sys.server_resource_stats in Azure Managed Instance  returns aggregated data concerning CPU usage, IO and storage data.  It can also return things like the resource SKU, meaning whether you are using General Purpose or the Business Critical tier. The counterpart to this DMV for Azure SQL Database is called sys.dm_db_resource_stats.

This is already a long post and there is a lot I didn’t share or summarize.  I encourage you to research performance features like Intelligent Query Processing, Automatic Plan Correction and Automatic Tuning for Azure SQL Database.

 

I hope these takeaways have been informative and will inspire you to watch the videos and do some of your own research.

Azure SQL Boot Camp Day 1 Key Takeaways

Recently Microsoft hosted an Azure SQL Boot Camp over on the Microsoft Developer page on YouTube.  The boot camp consisted of four days of two hour sessions describing the different features of Azure SQL.  The hosts were Anna Hoffman and Bob Ward.

This will be the first of a four part series offering you key takeaways from each of the sessions.  These takeaway posts by their nature can’t possibly include everything from each session so keep that in mind as you read.

Why Would You Use Azure SQL VMs?

Azure VMs are Infrastructure as a Service. If your on-prem SQL Servers are working just fine, why would you switch to Azure SQL VM?

  1. You’re committed to migrating at least some part of your servers to the cloud and you want an easy entry point that feels most like your on-prem SQL Servers.  Azure Virtual Machines are just what they sound like. You get a VM in Azure’s cloud. Once you install SQL Server on the VM, it looks and feels like the SQL Server of old, because it is. You still have to do some Azure networking and configure access to it. This gets you a gentle introduction to Azure without changing your whole world all at once.
  2. You are committed to migrating at least some part of your servers to the cloud and you need on-prem, native SQL Serve features such as SSAS, SSRS or SSIS.  Possibly you need things like Distributed Transaction Coordinator, Linked Servers or FileStream. If you are using these features on-prem, and you don’t want to change anything about how your environment works, then you need Azure VMs.
  3. You are committed to migrating at least some part of your servers to the cloud and you need access to the operating system. If your application using your SQL Server needs to do something at the Windows file or other OS level then the Azure VMs offering is your only option.
  4. Your databases are on the Simple Recovery Model and you don’t want to change that. The other flavors of Azure SQL, namely Managed Instance and SQL DB, require the databases be in Full Recovery Model. Keep in mind though, that the Simple Recovery Model inhibits your ability to recover from a data disaster.So, think long and hard about whether you really want to keep things on that recovery model.
  5. You have SQL Server 2008 or 2008 R2 in your environment. These versions of SQL Server are out of support on prem.  This means no more security updates of any kind. No more adding features to the platform (non-security related updates).  If you break it you pay for it. Meaning, if you call Microsoft for help, they won’t help you for free. They may just tell you that you need to upgrade. But, maybe you have legacy apps that are tied to one of these versions of SQL Servers and you still want to migrate them to the cloud.  In that case, you have to use Azure SQL VMs. Good news, in Azure you can still get free updates to SQL Server 2008 and 2008R2.
  6. You can have automated backups and security updates handled by Azure.  With Azure handling this, your team has more time for other things.
  7. Accelerated storage performance with Azure BLOB Caching.
  8. Virtual networks to integrate with on-prem resources
  9. Azure VM built-in HA and Azure Storage built-in DR
  10. Failover Cluster Instance with Azure Premium file share.

How do you migrate to this. One way is to use Azure Site Recovery.

There is more about Azure VMs, but remember, I promised you only key takeways.

 

What Is Azure SQL Managed Instance All About?

Azure SQL Managed Instance is the next progression toward Platform as a Service. As you progress toward Platform as a Service, more and more features are managed by Azure, leaving you with more time for other things.

Here are some takeaways.

  1. You want to use this if your company wants to move to the cloud while removing more management and administrative overhead, but you need instance scoped features like SQL Server Agent, Database Mail, CLR, Linked Servers, Service broker, etc.
  2. Management overhead related to business continuity, high availability and DR are handled by Azure for you.  The nature of these features in Azure Managed Instance are determined by things like your service tier (General Purpose or Business Critical).
  3. The General Purpose Tier offers remote storage, involves the least money, but has only a single instance.
  4. The Business Critical Tier offers lower latency storage, a readable secondary, and has higher costs.

How do you migrate to this.  One way is near zero down time using log shipping.

What is Azure SQL Database All About?

Azure SQL Database is at the far end of the continuum of IaaS versus PaaS.  As a PaaS offering, basically everything but the database is stripped away. There is no access to file level structures or the OS.  Both server and instance level options to make changes are removed. So what are some characteristics of this offering?

  1. Fully managed service, meaning that the Azure service handles all SQL upgrades, patching, backups, high availability and monitoring. Thus, almost all administrative functions are handled by Azure. This provides you with the latest stable version of the SQL Server database engine.
  2. There is no ability to make configuration changes that require a server restart because Azure SQL Database does not provide access to the underlying server.
  3. Offers access to a single database with its own guaranteed amount of computer, memory and storage resources.
  4. Elastic Pools  in Azure SQL Database allow for multiple, single databases to be managed together, providing predictable behavior for multi-tenant scenarios.
  5. SQL Database offers General Purpose, Business Critical and Hyperscale  service tiers.  HyperScale provides storage for large databases (100TB+).
  6. You can mix a single database deployment with an elastic pool.

How do you migrate to Azure SQL Database? One way to accomplish a migration is discussed here.  You can also use the Azure Database Migration Service.

For any of these offerings, I didn’t cover things like the monitoring available with each of these in Azure portal, deployment options or connectivity architecture.

Azure has a lot to offer.  There are caveats and usage scenarios for each type of platform within Azure.  Please be sure to check out what is and isn’t available from a SQL Server features and management perspective within each offering.

Stay tuned for part 2 of Key Takeaways from the Azure SQL Boot Camp.

What Is the Value of Mentoring?

There aren’t many formal mentoring relationships these days. It seems to be rare when two people enter into an arrangement where one person agrees to give of their time energy and resources to answer questions and assist another person. Oh sure, you do it casually when you give an assignment to someone and say, “Let me know if you need any help.”

However, that’s different from a recent offer made to people in the SQL Server community. Paul Randal is once again offering his time to multiple people, inviting others to engage in discussion about non-technical subjects. To be sure, it is a unique and wonderful opportunity.

Why Look for a Mentor Now?

Blogging

I have had some career goals over the years. For a very long time I wanted to start a blog. Almost five years ago I finally started this blog. At first, I was posting fairly regularly. Yet, the posts began dropping off and are almost nonexistent. I would like to have a mentor so I could learn a process that works for me, enabling me to post at least once a week.

Presenting

Another goal I would like to reach is to start presenting. For a very long time I believed the lie that I didn’t know enough to be able to give back. Imposter syndrome was a big scary monster holding me back. I entered into the IT world back in 2008 knowing nothing about that world. I got into it because I happened to be a person who understood an important line of business application at my company. People noticed that, and I eventually began managing that software. I had no IT or Computer Science training. I still don’t have a Computer Science degree.

Recently I began to have access to some really smart people and found that I often handled SQL Server situations in ways that were similar or the same as them. By no means am I on their level, but I found that methodologies, ways of thinking and troubleshooting approaches were often the same. When I saw that, I began to really have confidence that I have something to offer other people. I have been given so much by the SQL Server Community. I want to give back.

Managing a Team/ Launching a Department

My current employer has been around since the 50’s. They never had a database administrator on the pay roll until they hired me in April 2018. In January 2020 I hired another DBA to work with me. I’ve managed people before, but not in technical environments and not another DBA. I am essentially launching a department from scratch. How do I do that? I’m figuring it out, but having someone to bounce ideas of off who is outside the situation could be incredibly beneficial.

Consulting

For about 5 or 6 years now I have given a lot of thought to opening my own business, starting a consulting company. I have recently watched a 2 hour presentation from Brent Ozar about how he did it and how he recommends other people attempt it. But a two hour presentation at PASS doesn’t cover everything. How do you pick tools to get the thing off the ground? If you’re going to do this with friends, how does that work, or should you just go it alone? When do you incorporate your work into a legal business? How do you turn a side hustle into a real business while avoiding legal entanglements with your employer over “work product?” These are all legitimate questions that I’m still trying to figure out.

Summary

So, there you have it. I want a mentor to help me with building a high quality blogging site. I want help with presentation skills, how to launch a department and to help me explore whether I should, or how I could, launch a consulting company. The value of mentoring for me is that I can receive some help so I can get that last nudge I need to start giving back and doing it in a meaningful, consistent way.