DBCC s
--Last input, 57 is the connection number (SPID)
--Displays the last statement sent from a client to an instance of Microsoft SQL Server.
DBCC INPUTBUFFER (57);
--DBCC OPENTRAN helps to identify active transactions that may be preventing log truncation
DBCC OPENTRAN
--Returns the current output buffer in hexadecimal and ASCII format for the specified session_id.
DBCC OUTPUTBUFFER(78)
--Displays information in a table format about the procedure cache
DBCC PROCCACHE
--DBCC SHOW_STATISTICS displays current query optimization statistics for a table or indexed view
DBCC SHOW_STATISTICS
DBCC SHOW_STATISTICS(t1,ix_t1) --table, index
--Provides transaction log space usage statistics for all databases.
DBCC SQLPERF
DBCC SQLPERF(logspace)
--Displays the status of trace flags.
DBCC TRACESTATUS(-1);--displays the status of all trace flags that are currently enabled globally.
DBCC TRACESTATUS (2528, 3205);--displays the status of trace flags 2528 and 3205.
DBCC TRACESTATUS (3205, -1);--displays whether trace flag 3205 is enabled globally.
--Returns the SET options active (set) for the current connection.
DBCC USEROPTIONS
--Checks the consistency of disk space allocation structures for a specified database.
DBCC CHECKALLOC
--Checks for catalog consistency within the specified database.
DBCC CHECKCATALOG (dbTest);
--Checks the integrity of a specified constraint or all constraints on a specified table in the current database.
DBCC CHECKCONSTRAINTS
--Checks the allocation and structural integrity of all tables and indexed views in the specified filegroup of the current database.
DBCC CHECKFILEGROUP
--Checks the current identity value for the specified table in SQL Serve
DBCC CHECKIDENT
DBCC CHECKIDENT(RandomData)
--Checks the integrity of all the pages and structures that make up the table or indexed view.
DBCC CHECKTABLE(RandomData)
--Checks the logical and physical integrity of all the objects in the specified database by performing the following operations
DBCC CHECKDB
--Reclaims space from dropped variable-length columns in tables or indexed views.
DBCC CLEANTABLE (dbTest,'T1', 0)
--Rebuilds one or more indexes for a table in the specified database.
DBCC DBREINDEX(T1,ix_t1)
--Removes all clean buffers from the buffer pool.test queries with a cold buffer cache without shutting down and restarting the server.
DBCC DROPCLEANBUFFERS
--Removes elements from the plan cache
DBCC FREEPROCCACHE
--Defragments indexes of the specified table or view.
DBCC INDEXDEFRAG
DBCC INDEXDEFRAG(dbTest,'T1',ix_T1)
--Shrinks the size of the data and log files in the specified database.
DBCC SHRINKDATABASE (dbTest);
--Shrinks the size of the specified data or log file for the current database
DBCC SHRINKFILE (dbTest_Log,2)
--Reports and corrects pages and row count inaccuracies in the catalog views.
DBCC UPDATEUSAGE (0); --0 is the current database
--returns syntax information for the specified DBCC command.
DBCC HELP ('SHRINKFILE')