🗄️ SQL-Server
(47 posts)
T-SQL queries, performance tuning, security management, and administration guides for Microsoft SQL Server.
📅 2019-02-11
✍️ Bart Schelstraete
If you copy (backup/restore) a database from system A to system B, it is possible that the SQL users won't be able to login, and this is because the GUID/SID of the users on system A doesn't match…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Not all SQL scripts should be short ;) The T-SQL code below will list the SQL Agent job history. SET NOCOUNT ON --Checking for SQL Server verion IF…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
SQL Server is of course caching data in order to minimize access to disks. Sometimes you want to clear that memory, for testing purposes for example. You can use DBCC commands in order to clear the…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
When you are looking for the creation date/time of certain tables, you can easily find that in the sys.tables. You can use the code below to list all tables and the creation date of those tables.…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Sometimes you need to know when a SQL login was created. The SQL code below will list the SQL logins, when they were created, and whether they are enabled or disabled. SELECT 'Server[@Name=' +…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
The T-SQL code below will give you the top 10 most CPU-consuming SQL statements in your database, sorted by CPU time. SELECT TOP 10 qs.total_worker_time/qs.execution_count as [Avg CPU Time],…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Disk I/O is most of the time the bottleneck of your SQL database, even when using SSD. The SQL statement below will show you the most disk I/O-intensive statements, which you should look to improve.…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
The code below will give you the top 10 most executed stored procedures in your database, sorted by execution count. SELECT TOP 10 dest.text, deqs.execution_count, deqs.total_worker_time,…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
Interested in seeing how long your SQL Server Agent has been up and running, or want to check if that agent is operational? You can use the T-SQL code below to find out: SET NOCOUNT ON DECLARE…
Read more →
📅 2019-02-11
✍️ Bart Schelstraete
The SQL statement below will give you the top 100 longest running SQL statements in your database, sorted by duration. SELECT TOP 100 qs.total_elapsed_time / qs.execution_count / 1000000.0 AS…
Read more →