Today I want to share how I’m keeping a copy of instances’ configurations using dbatools .

Chrissy LeMaire ( B | T ) wrote about it before on the Simplifying disaster recovery with dbatools blog post. In this post, I will add one step and save the output on a GIT repository.

Pre-requirements

  • You need a GIT repository
  • GIT tools installed on the server where you are running the script so you can commit your changes
  • dbatools
  • A list or a place to get all instances that you want to run the export

Preparation

Git repository

Clone your repository to a location where dbatools can write to.

Continue reading

Continuing to share tips and tricks using dbatools like the Refresh databases that belongs to availability group using dbatools posted a few days ago, today I will share a way to export the permissions of a login/user at instance/database level and apply them to a new login/user.

The typical request

Client: “We have a new colleague, can you please grant them the exact same permissions I have?!”

A quick note/suggestion that may help minimize your work: If we are talking about a Windows Login, please suggest the use of AD groups to help you (so that you don’t need to do this process) and also them (they don’t need to make this request).

Continue reading

Just a quick post as may help any of you searching for this.

Scenario

Client wants to analyze most recent deadlocks that happened on a specific instance. They asked us to send the xdl files.

How do we get the deadlocks?

Depending on the version of SQL Server that you are running, there are different ways to do it. In this post I will share how you can do it from all files that belongs to the system_health extended event session. (Not only the current file). This works on SQL Server 2012 or higher version. For a better overview I recommend you to read the What are SQL Server deadlocks and how to monitor them article from SQLShack.

Continue reading

Few days ago I was surfing on Twitter when dbatools asked about how it’s PowerShell module changed the way people work .

Open and check the answers given by the community as there is really good stuff there!

My turn

I have shared one of my recipes related to database refreshes. You know, when the client says, “please restore this backup or the most recent backup on our instance.”. But what if the databases belong to an availability group? It’s not as simple as a standalone installation.

Continue reading

Disclaimer: The title is my assumption because I saw it in the past happening this way.

This blog post aims to make you remember something: something that is obvious to you, might not be obvious to others.

Scenario

A client has a process which consists of a stored procedure that wraps a bunch of other stored procedures. The process runs for about 10 hours.

Taking a look…what is running right now?

I was curious about the process, I’ve seen this running before but never explored the code. After a couple of days of seeing it running for so long, I decided to see what would be the random query I would get executing.

Continue reading