I.T. minded
SQL-Server
T-SQL : find schema modifications which occurred the last day
In SSMS you have the “schema changes history” report. You can have the same (or even more) details from T-SQL. You can use the t-sql statement below in order find schema changes the last day, in a particular database.
SSRS: Find out memory used by reporting service.
The T-SQL code below will give you an idea of the memory used by your reporting service. This query should be executed on the “reportserver ” database. Please be aware executing this statement can take some time.
T-SQL: Check progress of DBCC checkdb
Doing a dbcc checkdb can take a lot of time, and in case of corruption you really want to see the progress. You can use the t-sql statement below to find the progress. Keep in mind to replace the YOUR_DB_ID…
T-SQL: List transactions & log used
The code below will list the transactions on the instance, and it will also include the size of the log which is used for that transaction.The output is ordered by log size. You can also use the below to find…
T-SQL: List modified objects using default trace
You can use the default trace in SQL server in order to track CREATE/DELETE/ALTER DDL operations.The T-sql code below will show the CREATE/DELETE/ALTER DDL operations visible in the default trace.
T-SQL: Check progress of backup/restore
Backups/restores can take a lot of time, but when it’s running, you want so see the progress.By executing the handy T-SQL code below, you can see the progress of the backups/restores on your system.
T-SQL: Remap SQL users
If you copy (backup/restore) a database from system A to system B, it is possible that the SQL users won’t be able login and this because the GUID/SID of the users on system A doesn’t match the GUID/SID of system…
T-SQL: List SQL Agent jobs history
Not all SQL scripts should be short 😉 The T-SQL code below will list the SQL Agent job history.
T-SQL: Flush memory cache for testing purposes
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 system / proc /…
T-SQL: Creation date/time of tables
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 in order to list all tables, and the creation date of those tables.
T-SQL: Find the creation time of SQL accounts
Sometimes you need to know when a SQL login was created. The SQL code below will list the SQL logins, when this was created, and if this is enabled or disabled.
T-SQL: Find most CPU consuming statements
The t-sql code below will give you the top 10 most CPU consuming SQL statements in your database, sorted by CPU time.
T-SQL: Find most I/O heavy SQL statements
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 heavy disk I/O statements, which you should improve.
T-SQL: Top most used stored procedures
The code below will give you the top 10 most executed stored procedures in your database, sorted by execution count.
T-SQL: show uptime of SQL server & and status of agent
Interested to see how long your SQL server agent is up and running, or you want to see if that agent is operational? You can use the t-sql code below to find out:
T-SQL: Top long running SQL statements
The SQL statement below will give you the top 100 longest running SQL statements in your database, sorted by duration.
T-SQL: Find table in complete instance
Looking for a table, but you don’t remember in which database it’s located? The code below will create a stored procedure, which you can use in order to find a table in multiple databases.
T-SQL: Show sizes of all tables in a database
You can use the t-sql code below in order display the size of each table in a specific database.
T-SQL: Kill all connections to a specific database
Sometimes you need to do maintenance on a database, and you don’t really want to use single user mode or disable accounts. In that situation you could kill all connections to a specific database.In order to achieve that, you can…