At SQLUndercover we decided it would be a good idea to not only upgrade our test lab but to treat it as if it were a live system carrying out an in place upgrade with minimal downtime, here's how we did it: Here is our very basic setup for this scenario, we have two availability... Continue Reading →
UNDERCOVER TOOLBOX: sp_RestoreScript – A Painless way to generate SQL Server database restore scripts.
(Latest Version 1.8 - 23 November 2020) I'm sure we've all been there, we need to restore a database to 11:34am, four days ago. What's the first step? To go off hunting down the relevant full and differential backups and then figure out what transaction logs we need to play in and in what order.... Continue Reading →
Joining Datasets Side by Side, in Their Natural Order When There’s No Common Key
Here's a little something that came up the other day, we've got a couple of tables which we need to join together but there's no common key to join on. How do we go about attacking this? As an example consider the following, we've got two comma delimited strings that we need to join together.... Continue Reading →
Generating Random Numbers For All Rows in a Query and Other Funky Stuff You Can Do With Them
UPDATE: Check out Generate a Random Number for Each Row in a Query {a better way} for an alternative method that I now use for generating random numbers using CRYPT_GEN_RANDOM Here's a lunchtime quickie for you all, this is something that I've seen asked on the forums plenty of times and always gets some quite... Continue Reading →
Using SQLCMD Mode for Always On Availability housekeeping.
One way i tend to query multiple servers in one go is to use Registered servers, but there are times when I might need to run something against a specific set of servers which i do not have a Registered servers group for, or maybe i need to select these servers dynamically. Maybe i do... Continue Reading →
UNDERCOVER TOOLBOX: Sp_FailedJobs the quick way to check for Failed Agent Jobs.
I know I know, Why not just use the GUI right? well that's ok but sometimes the GUI just takes too long for me...maybe I am a little impatient but sometimes I just need something to run that will give me the answers in just a couple of seconds with the touch of a button.... Continue Reading →
Database in ‘Recovery Pending’ After Transaction Log Backup
Here's a little issue that I came across last week and I thought I'd share my investigations with you. Users started to report that a database was inaccessible and when I had a look, sure enough the database was in 'recovery pending' state. That's odd, a database usually only goes into 'recovery pending' state at... Continue Reading →
UNDERCOVER TOOLBOX: sp_FailedLogins, Capture those failed logins with ease.
Here is a relatively simple yet effective stored procedure to quickly view those failed login attempts (an alternative to viewing the SQL Server Error log manually and filtering). There are other ways of getting this information, but we liked the idea of having a stored procedure that we could run Ad hoc when we wanted. Its... Continue Reading →
Dude where’s my access?
Here is a little quickie for a Friday afternoon , one for the back pocket maybe? Here is a scenario that you may have been faced with before, I am pretty sure we all have at some point but today I want to show a neat little way to get around this situation which does... Continue Reading →
UNDERCOVER TOOLBOX: fn_SplitString, It’s Like STRING_SPLIT But For Luddites (or those who haven’t moved to SQL 2016 yet).
When Microsoft announced STRING_SPLIT, cries of joy and jubilation could be heard all around the offices of SQL Undercover. For those of you who aren't aware of this miracle of the database world, we've finally got a way of converting a delimited string into a table. If you've ever written a proc or script where you... Continue Reading →