I was having a cleanup of some old scripts the other day when I stumbled upon a script I wrote some time ago. I remember writing the script because from time to time I would get asked if I can restore a copy of a specific database to a particular point in time... Continue Reading →
Selecting a Random Row From a Table
A couple of times recently I've seen the question asked, 'How can I select a single row at random from a table?'. There are often a few ways of doing this suggested, most seem to rely using CTEs or temp tables. I thought I'd share, in a quick post a very simple and easy way... Continue Reading →
T-SQL Tuesday #104 – My Undercover Toolbox favourites
This months T-SQL Tuesday is being hosted by Bert Wagner , you can find the invitation for this months topic here. Bert has a great topic for this month, he wants us to write about code you’ve written that you would hate to live without. I have found the SQL server community to be extremely helpful... Continue Reading →
Backup Your On Premise SQL Server Directly to an AWS S3 Bucket
UPDATE Aug 2024: With SQL2022, things have changed and we're now able to backup directly to S3 without the need for third part tools. Check out how to do that here... Backup SQL Server to AWS S3 Bucket (2022 Update) I've been having a little play around with AWS recently and was looking at S3 (AWS'... Continue Reading →
Convert a Positive Number To a Negative In SQL With a Spot of Bitwise Logic
Now this is something that I've seen asked a few times and it's always a question that gets a fair number of different answers. How do we go about converting a positive number to a negative, or the other way around? I'll give you my solution and it uses a little bit of bitwise logic.... Continue Reading →
Digitally Signing a Stored Procedure To Allow It To Run With Elevated Permissions
Have you ever had the need to give elevated permissions via a stored procedure above that what the user calling the procedure might have? Perhaps you've got a table in your database that contains top secret information and you only want that information to be accessed by via a proc, you're users are denied access... Continue Reading →
T-SQL Tuesday #101 – My day of Essential SQL Server tools.
This month’s T-SQL Tuesday is brought to you by Jens Bestergaard - the subject is Essential SQL Server tools, the original invitation can be found here. Here is how my day of using SQL tools went: It all started at 00:00 this morning with planned maintenance, I was adding a bunch of Clustered indexes... Continue Reading →
Encrypting SQL Server Database Backups
We all go to great lengths to make sure that our databases are secure (or at least I really hope that we do), we make sure that only authorised users have access and then only to the databases and levels that they need. We're careful that all our passwords conform to crazy complexity rules. We're... Continue Reading →
‘Object Reference Not Set to an Instance of an Object’ When Failing Over an Availability Group Using SSMS <= 17.5
Here's a quickie that I've just stumbled across. I've just tried to initiate a manual failover of an availability group and received the following error. After a spot of head scratching and thinking that there was something wrong with my AG setup, it turns out that there's a bug in SSMS. I was running SSMS... Continue Reading →
TempDB Filling Up On Secondary Replicas
Have you ever had an issue where TempDB was filling up on your secondary replicas? Do those secondaries happen to be read only replicas? When I have an issue with tempdb filling up the first thing that I usually do is try to figure out exactly what the space has been allocated to. You can... Continue Reading →
