If there’s one thing every Scooby-Doo episode teaches us, it’s that solving mysteries is a team skill. The gang doesn’t stumble onto answers by luck (well… except when Scooby and Shaggy fall into secret passages). They solve the case because they know how to spot the clues and put them together. Performance tuning in SQL Server works the same way. If you don’t know where to look—or how to interpret the trail of breadcrumbs—you’ll spend more time running from shadows than unmasking the real villain. I see this practically every day. SQL Server Always Leaves Clues Just like Velma dropping and leaving her glasses behind, SQL Server leaves clues all…
-
-
It is widely known that I am a horrible speller and hate to type code. I tend to use a lot of code snippets and reuse code to avoid writing it. So, when I find little tips that make coding easier for me, I like to share. Did you know that you can surround your code with a click of a button with IF, BEGIN END, WHILE code blocks? SQL Server Management Studio (SSMS) gives us the basic structure of a Transact-SQL statement code block as a starting point. Take Look In SSMS In a query window, Right Click and Choose Surround With (note the hot keys of Ctrl+K or…
-
Here is a quick blog to show you something I discovered that I didn’t know existed. I was on a Skype call and noted that the presentation I had been watching was no longer audible. I tried messing with my volume, I made sure my sounds weren’t muted and played around with my speakers and still nothing. I could hear the skype call without issues, but I wanted to multitask and continue to listen to the presentation. Finally, a light bulb went off and I thought maybe windows was “doing me a favor” and turning off all noises why I am on Skype. Sure, enough it was. If you look…
-
Are you using your Model Database to its full potential? I am finding more and more that Database Admins are not using the Model database to its fullest potential and some not at all. What is that Model Database for? The model database is basically the default setup (template) for all other databases created on a SQL Server instance. All databases created after install will inherit the properties of this database. Why Configure It? Using the model can insure consistency within your environment and is a quick way to automate your database setups. Below is a list of things I’ve used in my environments and others. Top (in no particular…
-
Okay, here is a pet peeve of mine, I think every stored procedure, function, view etc. should all contain a block of code I refer to as a preamble. If yours doesn’t I strongly recommend you start adding it. It drives me crazy when I see code with no documentation of any kind telling me what it is for and when it was written or changed. Why? A preamble documents the use, need, and changes for the code. It also leaves bread crumbs as to how why and what you did. I don’t know about you but I may code something and not have to change it for two years.…
-
OK So, I am doing some digging and peaking around again in SQL Server and came across a database option called Date Correlation Optimization Enabled = False. Honestly, I had no clue what it did, so I took it as a learning opportunity to look into it and do a little research. Who knows, it may actual help me solve one of the many problems I run into day to day for clients. Syntax ALTER DATABASE DEMO SET DATE_CORRELATION_OPTIMIZATION ON; So, What Does It Do? According to MSDN – The DATE_CORRELATION_OPTIMIZATION database SET option improves the performance of queries that perform an equi-join between two tables whose date or datetime columns are correlated,…
-
We have all made mistakes in our careers, I thought I’d share one of mine as a quick tip to others so that you don’t make the same one. Everyone has their SQL Alerts setup right? If not, I have included the script below and here is the MSDN link to find out more (https://msdn.microsoft.com/en-us/library/ms180982.aspx). For those who have setup their alerts, how many of you have remembered to set the DELAY BETWEEN RESPONSES setting? When I worked at the Port of Virginia, I was a little less experienced in SQL and didn’t notice this lovely little option. I of course failed to set it. Can anyone guess what happened?…
-
Ever had users come to you and request another version of a report just to add another field and group data differently? Today, was such the day for me. I really don’t like have multiple versions of the same report out there. So, I got a little fancy with the current version of the report and added a parameter then used expressions to group the data differently and hide columns. For those new to SSRS I’ve embedded some links to MSDN to help you along the way. Current Report The report gives summarized counts by invoice date. It currently has a ROW group using date_invoiced and the detail row is…
-
I think sometimes those of us that have been doing database administration/development for a while take it for granted that everyone knows the basics. One such basic is parameterizing stored procedures. This allows us to potentially consolidate multiple stored procedures into a single procedure. It’s as simple thing to do that many don’t. I try to parameterize as many stored procedures as possible. This not only minimizes the amount of procedures I need to maintain, it in my opinion is a much cleaner way to code. It disturbs me when I see multiple stored procedures that pull the exact same data, but may have slight differences between them. Whether it…
-
Recently, I was tasked to find all stored procedures in a database that use a particular table and change them to utilize another table. I needed to get this done quickly so I decided to think simple. Since it was a quick and dirty answer I figured I would share, it’s not rocket science, but useful none the less. The quick answer that I came up with is to script out all of the stored procedures into a single query window. This can be done easily through the GUI. Once that is complete, I can easily do a “Find & Replace” on the table name and we’re done! Let me…


























