When we create new users in databases that belong to an Always On Availability Group in SQL Server, we want them to work even if they failover to a Secondary node, but when we create a new login in a SQL… read more
How do we collect the actual execution plan from queries using Extended Event and how do we read its data
In an earlier article we saw how we activate the Query Store to monitor the performance of the queries and the plan they ran. But as we said, the Query Store has quite a performance impact, so we may want some lightweight profiling. In this... read more
How do we automate the process of checking the integrity of databases in SQL Server without using a maintenance plan
From time to time we have to check the integrity of our bases for any corruptions. In this article we will see the easiest and most efficient way to check for corruption in all instance databases. This… read more
How to bulk detach / attach databases in SQL Server
Sometimes we will need to move databases to SQL Server. This process can also be done with backup / restore or by changing the status of the base to offline, but in the article we will deal with the detach and attach processes. read more
How we collect deadlocked queries via Extended Event and how we read its data
In an earlier article we saw how we create an Extended Event to see queries with a long duration. In this article we will build Extended Event that records deadlocks. All we need to do is create it with a T-SQL command. After… read more
How can we from SQL Server read Excel / CSV / TXT and insert the records into a table
SQL Server allows us to read and import files at will without the use of SSIS (Integration Services) and Wizard packages. This process is done using the OPENROWSET function and the BULK INSERT. We can… read more
How can we see what CPU Usage we had per minute in SQL Server
SQL Server during its installation creates a lightweight Extended Event with a size of up to 5mb in which it records performance information. This Extended Event is called system_health and in this article we will see how we can with… read more
How can we find when a database was last used in SQL Server
In the article we will see an easy and quick way to see which databases are in use and which users are currently connected to them. To see when a database was last accessed in... read more
How can we run multiple SQL Scripts in SQL Server from within Windows with batch script
In this article we will see an easy way to be able to run SQL Scripts en masse in SQL Server with batch script and keep the results for each separately in CSV. The example Suppose we have… read more