🗄️ SQL-Server
(47 posts)
T-SQL queries, performance tuning, security management, and administration guides for Microsoft SQL Server.
📅 2021-12-28
✍️ Bart Schelstraete
If you are using SSMS 17 or 18, you may have noticed that the SSMS startup can be very slow, which is annoying for everyone. There are 2 workarounds which could resolve this issue: Open Internet…
Read more →
📅 2021-10-28
✍️ Bart Schelstraete
The T-SQL code below lists the currently running SQL Agent jobs. SELECT ja.job_id, j.name AS job_name, ja.start_execution_date, ISNULL(last_executed_step_id,0)+1 AS current_executed_step_id,…
Read more →
📅 2021-10-05
✍️ Bart Schelstraete
You can monitor TEMPDB usage by using the following SQL statement. SELECT COALESCE(T1.session_id, T2.session_id) [session_id] , T1.request_id , COALESCE(T1.database_id, T2.database_id) [database_id],…
Read more →
📅 2021-09-29
✍️ Bart Schelstraete
The code below can be used to query the linked servers & the user assigned to them. select s.name, p.principal_id, l.remote_name from sys.servers s join sys.linked_logins l on s.server_id =…
Read more →
📅 2021-09-01
✍️ Bart Schelstraete
With this command you can check the number of transactions in the distribution database. SELECT count(*) FROM [distribution].[dbo].[MSrepl_transactions] where entry_time > '2021-08-31…
Read more →
📅 2020-07-17
✍️ Bart Schelstraete
The SQL statement below will kill all sessions from a specific user that were not active in the last hour. Of course, change 'my_user' with your preferred user ID. If you want, you can also uncomment…
Read more →
📅 2020-07-16
✍️ Bart Schelstraete
Automatic seeding for SQL Always On is nice, but in the case of big databases this can take some time. Of course, it can be annoying if something is running and you don't see the status of it. The…
Read more →
📅 2020-03-25
✍️ Bart Schelstraete
On the distribution database, you can execute the statement below to get the sizes of the internal replication-specific tables USE distribution GO SELECT Getdate() AS CaptureTime,…
Read more →
📅 2020-03-25
✍️ Bart Schelstraete
You can use the code below on your distributor in order to check the backlog of the replication. SELECT (CASE WHEN mdh.runstatus = '1' THEN 'Start - '+cast(mdh.runstatus as varchar) WHEN…
Read more →
📅 2020-02-17
✍️ Bart Schelstraete
You can use the T-SQL code to resume/suspend all databases from the Always On group. The code below will resume SQL data movement for all databases: declare @cmd varchar(max) declare @cmd_suspend…
Read more →