I’m going to change things up a bit today with a blog post that isn’t SQL related. Instead, it is about an interesting troubleshooting experience I feel like sharing. My wife walked in the other night saying she was working on her PC, had walked away, and when she returned she noticed her PC was … Continue reading Testing a Power Supply with a Paper Clip
When it comes to error handling or troubleshooting a long stored procedure, RAISERROR is an easy statement to use that gets the job done. Way back in SQL Server 2012, Microsoft wanted to replace RAISERROR with the new (arguably less convenient) THROW statement. I thought it would be worth looking at an example using THROW … Continue reading THROW Statement Usage
There may come a time when you find SQL Server not coming up with the most efficient plan for executing a query. What happens when you have an index that is getting left out even though it would be an improvement over what is chosen by SQL Server? For these situations, you can use index … Continue reading Tread Carefully With Index Hints
Mainstream support for SQL Server 2016 officially ended yesterday. If that sounds scary and caught you by surprise, don’t worry. There’s certainly no reason to panic if you’re on SQL Server 2016 and I’m sure many people will be for years to come. What Does That Mean Going Forward? While there will still be releases … Continue reading SQL Server 2016 Mainstream Support Ends
Have you ever wanted to get the combination of each row in one table with each row in a second table? You may know this as a cartesian product in mathematics. In SQL Server, we can accomplish this by using CROSS JOIN. Like the Way You Look Team jersey and jersey combinations are very important … Continue reading Combinations with Cross Join
What if you’re moving a database to a new server by detaching and re-attaching database files and someone (not you of course) loses the log file? What if an old database needs to be brought online but the person coming to you only has an mdf file? Can you still attach the database in these … Continue reading Attach Database Without Transaction Log File
Anytime you run a query, SQL Server needs to build an execution plan to use as directions for best executing that query. These execution plans can be stored in your plan cache to be reused in the future if that same query is ran. Instead of resources going into rebuilding the plan each time, SQL … Continue reading Benefits of Optimize for Ad hoc Workloads
Are you not getting the type of performance you’re expecting on a brand new server? Did performance suddenly drop on an existing server even though hardware hasn’t changed? If you are dealing with either of these scenarios, it’s time to double check the Power Plan settings on your SQL Server. There might be an easy … Continue reading What’s Your SQL Server Power Plan?
Just as the LAG function can look at a previous row in a data set, the LEAD function can look ahead. I went through an example of the LAG function so now it’s time to take a look at LEAD. Cleveland Rocks For our LEAD function example, we’ll work with a couple Cleveland Browns player … Continue reading Using the LEAD Function in SQL Server
The LAG function in SQL Server allows you to work with a row of data as well as the previous row of data in a data set. When would that ever be useful? If you’re a sports fan, you’re familiar with this concept whether you realize it or not. Let’s look at an example. Need … Continue reading Using the LAG Function in SQL Server
Something went wrong. Please refresh the page and/or try again.
Follow My Blog
Get new content delivered directly to your inbox.