Backups – They Are Needed, Who Knew?

CollaborateImageBackups are essential for a successful business model. That statement may or may spark some topics for debate, but at the end of the day if the data professional does not have a form of backup in place for his/her business needs you may, no you will, feel the pain. It may not happen today, tomorrow, next week, but you can with 100% certainty guarantee that at some point in ones career you will need a backup of your database.

Importance

Let me start off this way and ask a very simple question, “Do I have to take a backup?” The answer to that is yes, yes you do. If you are a data professional than you should care about your data enough to take a backup of it in some form or fashion.

Types of Backups

Full Backup – this type of backup contains all the data for a specific database.

Differential Backup – think about this backup as what it’s name states; contains only the data since it’s last differential base backup; you can find these backups to be smaller in nature versus the full backup methodology

Transaction Log Backup (T-Log Backup) –  this type of backup is a record of all transactions that have been performed against the database since the transaction log was backed up. Most often times these types of backups are taken on a more frequent basis.

**Note** the differential and transaction log backups are both dependent upon the full backup initially being executed.

Disaster Recovery

Depending on how extensive your business model is some companies will rely on backups for their disaster recovery planning. Whether you log ship, utilize always on, restore databases periodically etc. backups can and will always be an essential part of disaster recovery.

Tuning Backups

Most people don’t realize that they can tune their backups. One of the ways you can do this is by turning on some trace flags and increasing some throughput. Below are two statements you can utilize.

DBCC TRACEON (3605, -1) and DBCC TRACEON (3213, -1)

What those two statements do is tell you (in your error log) what the settings are set to

clip_image002

The buffer count and maxtransfersize are the two settings you want to check. Make note of what the settings are initially; then when backing up your database, whether by a stored procedure or method of choice, you can include the following code.

WITH COMPRESSION
, BUFFERCOUNT = 800
, MAXTRANSFERSIZE=4194304

**NOTE – never take code from the web and execute it in production. Utilize this in a testing environment to see how it performs.

This little trick was picked up by watching the mighty Sean McCown at PASS Summit 2014 in one of his sessions.

Testing Backups

Wait, what? You mean I need to test my backups. Let me pose this question another way. If you take a solid backup and you store it for a certain period of time; then how do you know if you can restore it or not? Taking backups are only half the process; I used to think early on in my career that I was golden to have a backup versus the people who don’t take backups at all. Sure that is somewhat true but the flip side to that is I was missing the bigger picture; periodically test your backups. In a perfect world an automated process would restore backups to an isolated environment then fire off an alert if you find one that could not be restored. Most shops don’t or can’t go to that extent so at the minimum periodically test your backups for validity. Not only will it prove that your backups are working but will keep your skill set honed in the restoration process.

Wrap Up

Backups – they are important. As with anything in your data professional career; take this concept to be very important. If you aren’t backing up your data than I suggest you start. If you are backing up your data; then are you sure you can restore it? Are your backups taking forever; perhaps you can tune them? I tell you what…keep reading below and you can check out what some of my colleagues have to say around backups. Enjoy

On a SQL Collaboration Quest

Four SQL professionals gathered from the four corners of the world to share their SQL knowledge with each other and with their readers: Mickey Stuewe from California, USA, Chris Yates from Kentucky, USA, Julie Koesmarno from Canberra, Australia, and Jeffrey Verheul from Rotterdam, The Netherlands. They invite you to join them on their quest as they ask each other questions and seek out the answers in this collaborative blog series. Along the way, they will also include other SQL professionals to join in the collaboration.

SQL Sentry Plan Explorer – Don’t Leave Home Without It

CollaborateImageIf you’ve been around me long enough then you realize that I am a Red Gate fanatic. With that said I’ve grown accustomed to another utility called SQL Sentry Plan Explorer by SQL Sentry.

I’m a big Aaron Bertrand (B|T) fan and he is the one that first introduced me to this utility via his blog; if you aren’t following this man then you are missing out. He has some stellar commentary on his blog and twitter and has a deep passion for the SQL Community.

What is SQL Sentry Plan Explorer

One thing that I think of when the words SQL Sentry Plan Explorer are said is query optimization. Do you have that one go to script or utility when you are troubleshooting stored procedures and queries? If so, and this utility isn’t part of it then add it to your tool DBA tool belt.

There are two different versions that you can download; a free version and a Pro version. Both utilize SQL Server to help streamline and make optimization of queries become more efficient for the every day data professional.

What does the Free Plan offer

The free plan offers quite a bit. You can check out the overview here

  1. Enhanced plan diagrams
  2. Statements tree
  3. Plan trees
  4. Top operations
  5. Query columns
  6. Join diagrams
  7. Parameters
  8. Expressions
  9. I/O

These are just a few of the things you can expect to see with the free version

What does the Pro plan offer

In addition to what the free plan offers you will find some of the following:

  1. Wait Stats
  2. Full Query Call Stack
  3. Open Deadlock files
  4. Plan Filtering
  5. Rotate plans

…and much more

Personal Approaches

In the past I have found that the free plan has allowed me to:

  1. Quickly identify bottlenecks
  2. Review and compare statements
  3. Review costly operations
  4. Review index seeks and scans

I think one of the most beneficial items that SQL Sentry has done for this utility is adding it as an SSMS add in.

Utility Downloaded, Now What?

Like any other tool, the goal is to help streamline and make the data professional more efficient. With that said, the data professional has to know the “why’s” and how things function within SQL; don’t utilize the tool as a crutch nor should you utilize the tool as a means to solidify commands like a robot.

A SQL community member and MVP has taught me (thanks Tim Chapman (B|T) that just because you have all these tools at your disposal you, yourself have to be able to connect all the dots which means what guys – learn and know what you are reading.

You see an index seek; great….now why?

You see that Plan Explorer is showing you a critical alert in red on index cost…great; why?

Don’t just simply follow a tool; know what you are looking at.

Conclusion

I highly recommend SQL Sentry’s Plan Explorer; from personal experience it is helped me on more than one occasion. You can view all they have to offer here.

Well done SQL Sentry; well done indeed.

I tell you what; check out what my other colleagues have to say on the matter and how they have benefited from this utility:

If you want to read more about the newly released SQL Search, don’t forget to check out these blog posts:

On a SQL Collaboration Quest

Four SQL professionals gathered from the four corners of the world to share their SQL knowledge with each other and with their readers: Mickey Stuewe from California, USA, Chris Yates from Kentucky, USA, Julie Koesmarno from Canberra, Australia, and Jeffrey Verheul from Rotterdam, The Netherlands. They invite you to join them on their quest as they ask each other questions and seek out the answers in this collaborative blog series. Along the way, they will also include other SQL professionals to join in the collaboration.

 

C-R-U-D The Basics

C-R-U-D The Basics

What is CRUD? Well, there are a lot of things I can think of when I use the term CRUD; however within the wonderful world of technology CRUD is an acronym that surprisingly enough, when I polled, didn’t really give a straight answer. That really surprised me; so with that said I will walk you through the basics of the concept.

C-reate

The letter “c” stands for create; more specifically inserting some form of data by various methods or means into a repository or holding take. I want to take this down to its simplest form which the below example will depict:

 

Insert

 

Inserting data into the PastHist table is as simple as the T-SQL query; but don’t just limit the thought of creation by this simplest form. You could have data being created through front end apps, SSIS packages, or many other methods.

 

R-ead

Depends on who you ask or talk to. The letter “r” can stand for read or retrieve. A simple retrieve statement can be a Select as below:

 

Select

 

SelectResults

 

What is this he didn’t use a NOLOCK – don’t worry I can save that for another blog post but as you can see in its simplest form retrieving the data out of the table you just inserted into is not that cumbersome.

 

U-pdate

The letter “u” can mean update or modify if you will. Let’s see how easy it is to do a simple update statement below:

Let’s update the name for our record to be John where the id = 1

 

Update

 

UpdateResults

 

As you can see the data has been updated and John is now our data set in the name field column.

 

D-elete

The letter “d” stands for delete or destroy. Below is a simple script to delete the data out of the table:

 

Delete

 

There are some methods I could have used to remove the data; such as Truncate Table but this is not the time or place for me to distinguish between the two. I chose the delete method on the search criteria of id = 1

Results after the deletion:

 

DeleteResults

 

Conclusion

This is breaking down C-R-U-D into its simplest form. Please do not limit your thinking to these very basic simple queries. Expound on it and your thought process on what all C-R-U-D entails. As with anything you find on the internet DO NOT take queries and just execute them blindly on any environment. Doing so makes you assume the risk.

What else are others saying?

I tell you what; check out what my other colleagues have to say on something they learned recently around C-R-U-D:

 

CollaborateImageOn a SQL Collaboration Quest

Four SQL professionals gathered from the four corners of the world to share their SQL knowledge with each other and with their readers: Mickey Stuewe from California, USA, Chris Yates from Kentucky, USA, Julie Koesmarno from Canberra, Australia, and Jeffrey Verheul from Rotterdam, The Netherlands. They invite you to join them on their quest as they ask each other questions and seek out the answers in this collaborative blog series. Along the way, they will also include other SQL professionals to join in the collaboration.

ISPACs – Got To Love Em

Being a DBA and working with various teams, I have become accustomed to deploying SSIS packages. I’ll even go back further and, dare I say, DTS packages (I hope everyone did not just fall on the floor while reading that). Now-a-days this Database Professional does more deploying packages than developing them; with that said I was pleased when 2012 came along.

When the newer version of SSIS was released it offered several new features, one of those features was building a deployment model thus producing an ISPAC file. I remember first coming across this and thinking, “Wow, this is all packaged up”. While I won’t go into the specifics of how to build the deployment I will show you the step by step process of deploying the ISPAC file.

Step 1

Locate the ISPAC file. Once located double click on the ISPAC file to gain entry into the deployment wizard.

Ispac

 

Step 2

What kind of Integration Services project do you want to deploy? Since we are dealing with an ISPAC file on our local directory we will select the source path we found from Step 1. Simply browse to the path location and click ok.

Source

 

Step 3

So you have your ISPAC file selected and you want to deploy it; where does it go? You have the capability to supply any Server Name for rapid deployment. The path reflects the SSISDB catalog which is required for SSIS 2012 packages to be deployed. If your SSIS package is already on the server you can simply choose to overwrite the existing file at deployment time.

Destination

 

Step 4

After you select the destination path; it is then time for review. The review section will provide you with a great overview of the Source path of the file being deployed and the destination location.

Review

Step 5

Once verified and the deployment button is hit we are off to the races. The ability to have quick insight into the deployment and the methodology to save the report for future use is stellar. If your deployment did fail; at this step you would be able to dive into the error in the result pain on the right hand side.

Deploy

 

Seems simple enough? The deployment method in SSIS 2012 has proved beneficial for myself and is a welcomed aspect. Earlier this year I completed a post on the utilization of PowerShell and how to deploy 2012 SSIS packages and that can be found here.

I tell you what; check out what my other colleagues have to say on something they learned recently around SSIS:

 

CollaborateImageOn a SQL Collaboration Quest

Four SQL professionals gathered from the four corners of the world to share their SQL knowledge with each other and with their readers: Mickey Stuewe from California, USA, Chris Yates from Kentucky, USA, Julie Koesmarno from Canberra, Australia, and Jeffrey Verheul from Rotterdam, The Netherlands. They invite you to join them on their quest as they ask each other questions and seek out the answers in this collaborative blog series. Along the way, they will also include other SQL professionals to join in the collaboration.

Alerts – Who Knew?

CollaborateImageThis week I am back at it with my SQLCoOp friends in sharing something new that we’ve learned since our last post. You ready? Great, pull up a chair and let’s see where this takes us shall we?

Wait a second…….do you hear that……..no, listen closer…….ALERT ALERT ALERT! Sirens seem to be going off all around and somehow we found ourselves in all hands on deck mode. Have you ever been there before? Chances are if you have worked in technology at all this has happened to you at one point in your career. If it hasn’t then eventually it will; trust me.

How do you handle such scenarios when they do come up? Reporting of alerts off your systems or applications can be very useful and while there are many ways to accomplish this I was introduced to an SSIS method I had to deploy this week. It made me dive in a little deeper and look into how the methodology behind it. If we break it down; it can be done so my analyzing 4 steps within the package.

Main Package:

SSISAlert

The main package will consist of a database call, a for each loop container, setting of a variables task, then a wsdl (windows service) by utilizing an expression. The intent of this post is to show how you can make these calls happen and not to go into depth of what is located within the procedures or wsdl file; that shall be something for another today or better yet this should set a foundation in place for additional research one can do…..thus the learning something new part.

Getting the Exceptions

The Get Exceptions Alert utilized a simple SQL Task editor; once you create this editor you will notice the below screen shot. To complete the set up simply fill in the name and description. The next two important properties are the most important of them all. The connection and the SQL Statement. The connection is simply the database to which you are making the connection to; the second is executing a stored procedure that will gather all the alerts by the application that need to be emailed out.

SQLTaskEditor

For Each Container

You remember the SQL Task Editor we set up in the first step; this next step is what takes that result set; loops through the iterations and gets a collection of the alerts to be sent. Part of the homework is setting up the return result set in the SQL Task Editor. Once that is complete then you set the result set in the ADO Object Source variable noted below; this will allow multiple iterations to flow through. In this case the selection of enumeration mode should be set to rows in the first table

ForEachContainer

Set Variables

One of the key components are the variables to which you will utilize. These may be different depending on the in depth alerting that is wanting to be accomplished but for simplicity sake I will list out what the one I ran across was utilizing. We will notice that we have seven variables that will be set.

  • Alert – the alert name
  • Alert Info – what is so fascinating about this alert
  • Alert Type ID – correlates back to the type of alert that was set off
  • Result – the result of the alert
  • Result Data Set – the data that caused the alert and in this case not used
  • Source Process – what process triggered the alert
  • Source System – what system did this come from

SettingVariables

Registering the Alerts

Registering the alert and sending the email notification is the last step to the puzzle. This is done by utilizing the windows task service editor within SSIS. As you can see I have a wsdl file located on my local drive in a directory called Windows Services. As I mentioned before, I will not be going into detail of the contents of the wsdl file; simply know that it will trigger the email notification. The result parameter will be fired off to a group of individuals to review on a time based period. That parameter value will be supplied in the output section of the Web Service Task editor.

RegisterAlerts

Conclusion

There are several ways to arrive at this same goal and I found this one to be unique and one that is not traveled often. The package can be set up to be executed by the Agent on a time based interval. Whatever the case may be and whatever method that you do choose the important part is to keep learning.

I tell you what; check out what my other colleagues have to say on something they learned recently:

On a SQL Collaboration Quest

Four SQL professionals gathered from the four corners of the world to share their SQL knowledge with each other and with their readers: Mickey Stuewe from California, USA, Chris Yates from Kentucky, USA, Julie Koesmarno from Canberra, Australia, and Jeffrey Verheul from Rotterdam, The Netherlands. They invite you to join them on their quest as they ask each other questions and seek out the answers in this collaborative blog series. Along the way, they will also include other SQL professionals to join in the collaboration.

RedGate SQL Search Has What????

CollaborateImageThis week I am back at it with my SQLCoOp friends in sharing the goodness of a utility that has helped us all ~ RedGate’s SQL Search plug in for SSMS.  This utility has always been helpful in perusing through the schema of any SQL architecture in the search for the gems that we as data professional look for.

The Quest

The outlook was grim and bleak recently one day at the shop. I could recall a portion of a job name and step name for that matter but couldn’t find it for the life of me. The server I was on at the time had a vast amount of jobs on it which I will save for another day.

I will admit frustration started to set in and I started to just open up a query analyzer and start writing some code then it dawned on me…..I had just downloaded a new version of RedGate’s SQL Search Utility. I recalled from the version that they extended the search into SQL jobs; at that moment it was like a light bulb went off in the old noggin.

Now, if we are honest, we all like to work smarter not harder and save time along the way; with that said I decided just to crack this utility open and give it a shot.

Let’s Go

First thing I needed to do was fire up SQL Search inside SSMS. To do this and for the sake of explaining I will be showing this use case on my local, because well, we shouldn’t be showing the world our prod servers now should we! As you can see below firing up SQL Search is simple an easy. While on my local instance if I click on the SQL Search highlighted icon it will bring me to my SQL Search screen where I can then expound on my search criteria.

FiringUp

I had to define my search; I knew a phrase in my job but didn’t know the whole name….so with that said typing in what I knew and not selecting the exact match I knew would pull back the full job name; or so I thought.

 

Phrase

Now this is where it gets really good and makes the SQL Professor very happy. RedGate decided to go on and throw job search functionality into their updated utility. If you click on the All Object Type drop down you will see a Server Object called jobs. Simply go ahead and check that. Now for my use case I went on ahead and checked them all.

Jobs

So, what have we done up to this point is type in our phrase, ensure the jobs server object is check then it’s giddy up and go time. After letting the search occur in all databases I find the results I’m looking for:

JobResults

My job name pulled back along with the actual step detail. Whoa wait, I had no clue I’d get the detail with it as well. Hats off RedGate this is something that every Data Professional can utilize and is a tool that saves time. It took me less than a minute to do a quick search and pull the information that I required.

Like What You See?

Listen, this just is one avenue in which RedGate has enhanced this product. I’m an everyday Data Professional that goes into work everyday and wants to work efficiently. Check this product out for yourself here

Some of the other enhancements made are:

  • Search in jobs
  • Select multiple object types and databases to search in
  • Improved indexing
  • Search with % wildcards
  • Search with Boolean operators

I tell you what; check out what my other colleagues have to say on the matter and how they have benefited from this utility:

If you want to read more about the newly released SQL Search, don’t forget to check out these blog posts:

 

On a SQL Collaboration Quest

Four SQL professionals gathered from the four corners of the world to share their SQL knowledge with each other and with their readers: Mickey Stuewe from California, USA, Chris Yates from Kentucky, USA, Julie Koesmarno from Canberra, Australia, and Jeffrey Verheul from Rotterdam, The Netherlands. They invite you to join them on their quest as they ask each other questions and seek out the answers in this collaborative blog series. Along the way, they will also include other SQL professionals to join in the collaboration.