Tag: END

Building a SQL Restore Script When Your Backup Runs

It is handy to have a SQL Restore script ready to go for every backup that you run.  Here is a script that will help with that.  

Posted in SQL Server Tagged with: , , , , , , ,

Determining how much of your data file has been modified

SQL Server 2017 introduces a new column in the sys.dm_db_file_space_usage system table. The column is modified_extent_page_count, which tells how many pages have been modified in your data file since the last full backup. What is really interesting about this is that with

Posted in SQL 2017, TSQL Tagged with: , , , , , , ,

My CheckDB Script

From time to time I get asked about checkDB, and there are many solutions out there, but I have one that I generally use that is very simple and does the job. The script below created a stored procedure in

Posted in Uncategorized Tagged with: , , , , , , ,

Temporary Stored Procedures #sproc

Yes, you can create temporary stored procedures by prefixing the name of the sproc with a #. The temporary stored procedure is sort of a “leave no trace” stored procedure that is only good for your session. If you use

Posted in TSQL Tagged with: , , , , , , ,

Drop a trigger after a specific date

  The question of how to delete a trigger after a specific date came up.  Here is what could be done. If you want to trigger to disappear after a specific date or time, you can just drop the trigger

Posted in TSQL Tagged with: , , ,

Updating SQL Server Statistics

Updating SQL Server statistics may not be as obvious as it may sound. Imagine this scenario. I invite you over for dinner and a game of Scrabble. After dinner, I start to do the dishes, while you set up the

Posted in Performance Tuning Tagged with: , , , , , , ,

Optimize for Ad Hoc Workloads

The Optimize for Ad Hoc Workloads server configuration can improve performance, and is extremely unlikely to negatively impact performance. This was a new feature that was introduced in SQL Server 2008, and as with many new features in SQL Server,

Posted in SQL Server Tagged with: , , , , ,

Database Corruption Challenge Week 7 – Alternate Solution

The alternate solution to the Database Corruption Challenge this week was created by Patrick Flynn. This solution is the only solution to successfully recover all the data without using any of the backups. If the challenge had been structured differently

Posted in Corruption Tagged with: , , , , , , ,

How Do You Check if a Database Exists…

How do you check if a database exists, drop it and recreate it for testing purposes? After running the Database Corruption Challenge for several weeks now, I have seen many scripts to drop and recreate a database. This makes it

Posted in Corruption Tagged with: , ,

Database Corruption Challenge Week 4 Results

It is my pleasure to announce the winners in the Week 4 Database Corruption Challenge. But first how about a rundown of challenge. In order to make up for the difficult time that Challenge #3 was issued, Challenge #4 was

Posted in Corruption Tagged with: , , , , ,