SQL Server – DBCC T-SQL Commands

 

/* Informational Commands ​​ */

 

DBCC​​ SQLPERF(LOGSPACE)​​ --View transaction log size info

GO

 

DBCC​​ SHOW_STATISTICS('Sales.SalesOrderDetail',​​ 'IX_SalesOrderDetail_ProductID')​​ --View query stats for table or indexed view object

GO

 

DBCC​​ USEROPTIONS​​ --View current connections user set options

GO

 

 

/* Maintenance Commands ​​ */

 

DBCC​​ DBREINDEX('Person.Person')​​ --Rebuilds indexes on a table

GO

 

DBCC​​ CLEANTABLE(AdventureWorks2012,​​ 'Production.ProductDescription')​​ --Reclaims unused spaced from tables

GO

 

 

/* Validation Commands ​​ */

 

DBCC​​ CHECKTABLE('Person.Person')​​ --Integrity check of table pages/structure

GO

 

DBCC​​ CHECKFILEGROUP​​ --Integrity check of filegroup structure/allocation

GO

 

DBCC​​ CHECKDB(AdventureWorks2012)​​ --Integrity check of database objects

GO

 

 

/* Misc. Commands */

 

DBCC​​ HELP('CHECKDB')​​ --Syntax information for DBCC statements.. use '?' for list

GO

 

DBCC​​ TRACEON(610)​​ --Turn on trace flag 610 (minimally logged inserts into indexed tables)

GO

 

DBCC​​ TRACEOFF(610)​​ --Turn off trace flag 610

GO

 

DBCC​​ TRACESTATUS(610)​​ --Check trace flag status

GO

 

 

Knowledge worth sharing...Share on linkedin
Linkedin
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Bookmark the permalink.

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *