sp_updatestats

Runs UPDATE STATISTICS against all user-defined and internal tables in the current database. Updates query optimization statistics on a table or indexed view. By default, the query optimizer already updates statistics as necessary to improve the query plan; in some cases you can improve query performance by using UPDATE STATISTICS or the stored procedure sp_updatestats to update statistics more frequently... » read more

sp_delete_jobsteplog

Removes all SQL Server Agent job step logs that are specified with the arguments. Use this stored procedure to maintain the sysjobstepslogs table in the msdb database.

sp_delete_backuphistory

Reduces the size of the backup and restore history tables by deleting the entries for backup sets older than the specified date. Additional rows are added to the backup and restore history tables after each backup or restore operation is performed; therefore, we recommend that you periodically execute sp_delete_backuphistory. The backup and restore history tables... » read more

sp_purge_jobhistory

Removes the history records for a job. Example Purge job history records older than 30 days. Sources: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-purge-jobhistory-transact-sql?view=sql-server-2017

PowerShell

PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language. Can be run as Jobs in SQL Server. Example Run Script From SQL Job Type: Operating system (CmdExec) Remove all files greater than a certain date. Type: PowerShell PowerShell Commands Here are 25 basic PowerShell... » read more

DBCC CheckDB

DBCC CHECKDB is used to check the physical integrity of the entire database. DBCC CHECKDB is used to detect corruption in the database, and should be run regularly.  This is accomplished by running several of the other DBCC commands, then doing some extra verification. Runs DBCC CHECKALLOC. Runs for every table DBCC CHECKTABLE. Runs DBCC... » read more

sp_cycle_errorlog

Every time SQL Server is started, the current error log is renamed to errorlog.1; errorlog.1 becomes errorlog.2, errorlog.2 becomes errorlog.3, and so on. sp_cycle_errorlog enables you to cycle the error log files without stopping and starting the server. Return Code Values 0 (success) or 1 (failure) Source: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-cycle-errorlog-transact-sql?view=sql-server-2017

TSQL: Replicas Database

Query to return info about replicas. Query to return a list of Primary Replicas databases. Query to return a list of Non-Primary Replicas databases.