/* ** SELECT OBJECT_NAME(id) as Object, SUBSTRING(text, PATINDEX('%dbcc%', text), 80) as Text FROM master..syscomments WHERE PATINDEX('%dbcc%', text) <> 0 ** */ /* ** Trace Flag 2520 displays ALL commands available in SQL Server 2000 ** Trace Flag 2588 displays ALL commands available in SQL Server 2005 ** Trace Flag 2588 displays ALL commands available in SQL Server 2008 ** DBCC TRACEON(2588) DBCC HELP ('?') GO ** */ /* ** To learn about syntax of an individual DBCC command run following script in query analyzer. ** ** DBCC HELP('') ** GO ** ** Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands. ** */ /* ** Returns the active cursor's parameters such as cursor ID, cursor name, cursor creation time, open/close state, and so on. ** DBCC activecursors [(spid)] ** DBCC traceon(3604) DBCC activecursors ** */ /* ** Adds an extended stored procedure. Use sp_addextendedproc as a documented way to accomplish the same thing. ** DBCC addextendedproc (function_name, dll_name) ** USE Master DBCC addextendedproc (sp_text, 'c:\xp_text.dll') */ /* ** Add an object instance to track in Performance Monitor ** DBCC addinstance ('objectname', 'instancename') ** DBCC addinstance ('Process Monitor', 'MMC') ** */ /* ** DBCC adduserobject (name) ** */ /* ** Turns on auditing for the specified event. Used in sp_dropremotelogin, sp_grantdbaccess, sp_addlinkedsrvlogin, sp_dropserver, sp_denylogin, and sp_adduser. ** DBCC auditevent (eventclass, eventsubclass, success, loginname, rolename, dbusername, loginid, objname, servername, providername) event class: enumerated in BOL under sp_trace_setevent eventsubclass: 0 | 1 | 2 | 3 success: 0 | 1 ** DBCC traceon(3604) DBCC auditevent (176, 1, 1, Dave, NULL, NULL, NULL, NULL, NULL, NULL) ** */ /* ** DBCC autopilot (typeid, dbid, tabid, indid, pages [,flag]) ** */ /* ** DBCC balancefactor (variance_percent) ** */ /* ** DBCC bufcount [(number_of_buffers)] /* ** Returns buffer headers and pages from the buffer cache. Printopt 0 outputs only the buffer header and page header (default); 1 outputs each row separately and the offset table; and 2 outputs each row as a whole and the offset table. ** DBCC buffer ( {'dbname' | dbid} [, objid [, number [, printopt={0|1|2} ] [, dirty | io | kept | rlock | ioerr | hashed ]]]) ** DBCC buffer ('AdventureWorks') ** */ /* ** Returns bytes from a specific address. ** DBCC bytes ( startaddress, length ) ** DBCC traceon(3604) DBCC bytes (1000000, 200) ** */ /* ** DBCC cacheprofile [( {actionid} [, bucketid]) ** */ /* ** Returns information about the object currently in the buffer cache such as hit rates, compiled objects, plans, etc. This command shows the number of pages used by the object plans, SQL plans, bound trees, extended stored procedures, temporary tables and table variables. ** DBCC cachestats ** DBCC traceon(3604) DBCC cachestats ** */ /* ** This command is used in sp_fulltext_database and sp_fulltext_service. ** DBCC callfulltext ** DBCC callfulltext - system sp use only ** -- updates the list of languages registered with full-text search service DBCC callfulltext (18) ** */ /* ** Checks the consistency of disk space allocation structures for a specified database. ** DBCC checkalloc [('database_name'[, NOINDEX | REPAIR])] [WITH NO_INFOMSGS[, ALL_ERRORMSGS][, ESTIMATEONLY]] ** -- Check the current database. DBCC CHECKALLOC; GO -- Check the AdventureWorks database. DBCC CHECKALLOC ('AdventureWorks'); GO ** */ /* ** Checks for catalog consistency within the specified database. The database must be online. ** DBCC checkcatalog [('database_name')] [WITH NO_INFOMSGS] ** -- Check the current database. DBCC CHECKCATALOG; GO -- Check the AdventureWorks database. DBCC CHECKCATALOG ('AdventureWorks'); GO ** */ /* ** Checks the integrity of a specified constraint or all constraints on a specified table in the current database. ** DBCC checkconstraints [( 'tab_name' | tab_id | 'constraint_name' | constraint_id )] [WITH ALL_CONSTRAINTS | ALL_ERRORMSGS] ** USE AdventureWorks; GO DBCC CHECKCONSTRAINTS ('Production.CK_ProductCostHistory_EndDate'); GO ** */ /* ** Checks the logical and physical integrity of all the objects in the specified database by performing the following operations: + Runs DBCC CHECKALLOC on the database. + Runs DBCC CHECKTABLE on every table and view in the database. + Runs DBCC CHECKCATALOG on the database. + Validates the contents of every indexed view in the database. + Validates the Service Broker data in the database. ** DBCC checkdb [('database_name'[, NOINDEX | REPAIR])] [WITH NO_INFOMSGS[, ALL_ERRORMSGS] [, PHYSICAL_ONLY][, ESTIMATEONLY][,DBCC TABLOCK] ** -- Check the current database. DBCC CHECKDB; GO -- Check the AdventureWorks database without nonclustered indexes. DBCC CHECKDB ('AdventureWorks', NOINDEX); GO ** */ /* ** DBCC checkdbts (dbid, newTimestamp)] ** */ /* ** Checks the allocation and structural integrity of all tables and indexed views in the specified filegroup of the current database. ** DBCC checkfilegroup [( [ {'filegroup_name' | filegroup_id} ] [, NOINDEX] )] [WITH NO_INFOMSGS [, ALL_ERRORMSGS][, PHYSICAL_ONLY] [, ESTIMATEONLY][, TABLOCK]] ** USE AdventureWorks; GO DBCC CHECKFILEGROUP; GO ** */ /* ** Checks the current identity value for the specified table and, if it is needed, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new seed value for the identity column. ** DBCC checkident ('table_name'[, { NORESEED | {RESEED [, new_reseed_value] } } ] ) ** USE AdventureWorks; GO DBCC CHECKIDENT ('HumanResources.Employee', NORESEED); GO ** */ /* ** Checks the allocation and structural integrity of the primary database. ** DBCC checkprimaryfile ( {'FileName'} [, opt={0|1|2|3} ]) Option 0: checks the that it is the primary database. Option 1: Returns name, size, maxsize, status and path of all files associated with the database Option 2: Returns the database name, version and collation Option 3: Returns the name, status and path of all files associated with the database ** DBCC checkprimaryfile ('G:\program files\microsoft sql server\mssql.1\mssql\data\northwind.MDF', 1) ** */ /* ** Checks the integrity of all the pages and structures that make up the table or indexed view. ** DBCC checktable ('table_name'[, {NOINDEX | index_id | REPAIR}]) [WITH NO_INFOMSGS[, ALL_ERRORMSGS] [, PHYSICAL_ONLY][, ESTIMATEONLY][, TABLOCK]] ** USE AdventureWorks; GO DBCC CHECKTABLE ('HumanResources.Employee'); GO ** */ /* ** DBCC cleanpage ( { 'dbname' | dbid }, fileid, pageid ) ** */ /* ** Reclaims space from dropped variable-length columns in tables or indexed views. ** DBCC cleantable ('database_name'|database_id, 'table_name'|table_id,[batch_size]) ** DBCC CLEANTABLE ('AdventureWorks','Production.Document', 0) WITH NO_INFOMSGS; GO ** */ /* ** /* ** DBCC clearspacecaches ('database_name'|database_id, 'table_name'|table_id, 'index_name'|index_id) ** */ /* ** Controls the on/off status of cache statistics. ** DBCC collectstats ( 'on' | 'off' ) ** DBCC collectstats ('on') ** */ /* ** In Microsoft SQL Server 2005, DBCC CONCURRENCYVIOLATION is maintained for backward compatibility. DBCC CONCURRENCYVIOLATION runs but returns no data. ** DBCC concurrencyviolation (reset | display | startlog | stoplog) ** DBCC concurrencyviolation (display) ** */ /* ** Returns the server's level DS_CONFIG information. DBCC resource also returns additional information. ** DBCC config ** DBCC traceon(3604) DBCC config ** */ /* ** DBCC cursorstats ([spid [,'clear']]) ** DBCC cursorstats () ** */ /* ** Returns the DBINFO structure for the specified database. ** DBCC dbinfo [('dbname')] ** DBCC traceon(3604) DBCC dbinfo ('AdventureWorks') ** */ /* ** Recovers a suspect database. ** DBCC dbrecover (dbname [, IgnoreErrors]) ** DBCC dbrecover ('northwind') ** */ /* ** Rebuilds one or more indexes for a table in the specified database one at a time. ** DBCC dbreindex ('table_name' [, index_name [, fillfactor ]]) [WITH NO_INFOMSGS] ** USE AdventureWorks; GO DBCC dbreindex ('HumanResources.Employee', PK_Employee_EmployeeID, 80); GO ** */ /* ** Rebuilds all indexes in a database. ** DBCC dbreindexall ( db_name | db_id [, type_bitmap ] ) ** DBCC dbreindexall ('northwind') ** */ /* ** Drops a damaged database. This feature is not available in SQL Server 2005. Use DROP DATABASE instead. ** DBCC dbrepair ('dbname', markdirty | {dropdevice, int} | {repairindex, int, int}) ** DBCC dbrepair ('northwind', markdirty) ** */ /* ** Returns the contents of the dbtable structure. ** DBCC dbtable [({'dbname' | dbid})] ** DBCC traceon(3604) DBCC dbtable ('adventureworks') ** */ /* ** DBCC debugbreak ** DBCC debugbreak ** */ /* ** Deletes an instance from Performance Monitor ** DBCC deleteinstance (objectname, instancename) ** DBCC deleteinstance ('Object_Name', 'Instance_Name') ** */ /* ** Returns the contents of the specified DEScriptor. ** DBCC des [( {'dbname' | dbid} [, {'objname' | objid} ])] ** DBCC des ('northwind') ** */ /* ** Detaches the specified database. Use sp_datach_db as a documented way to accomplish the same thing. ** DBCC detachdb [( 'dbname' )] ** DBCC detachdb ('northwind') ** */ /* ** Unloads the specified extended stored procedure DLL from memory. ** DBCC dllname (Free) ** */ /* ** Removes all clean buffers from the buffer pool. Use this command to remove all the test data from SQL Server's data cache between performance tests to ensure fair testing. ** DBCC dropcleanbuffers [ WITH NO_INFOMSGS ] ** DBCC dropcleanbuffers ** */ /* ** Used in the sp_dropextendedproc--the documented method to accomplish the same task. ** DBCC dropextendedproc (function_name) ** DBCC dropextendedproc ('xp_test') ** */ /* ** DBCC dropuserobject ('object_name') ** */ /* ** DBCC dumptrigger ({'BREAK', {0 | 1}} | 'DISPLAY' | {'SET', exception_number} | {'CLEAR', exception_number}) ** */ /* ** Truncate the current server log--essentially create a new log. A method to quickly control a log file that has grown quite large over time. Use the sp_cycle_errorlog as the documented method to accomplish the same goal. ** DBCC errorlog ** DBCC errorlog ** */ /* ** DBCC extentinfo [({'database_name'| dbid | 0} [,{'table_name' | table_id} [, {'index_name' | index_id | -1}]])] ** DBCC extentinfo ('Northwind') ** */ /* ** Returns the local file name, file size, growth increment and so on. ** DBCC fileheader [( {'dbname' | dbid} [, fileid]) ** DBCC fileheader ('northwind') ** */ /* ** THE SYNTAX IS BAD!!!!!!!!!!!!!!!!!!!! ** DBCC fixallocation [ ( {'ADD' | 'REMOVE'}, {'PAGE' | 'SINGLEPAGE' | 'EXTENT' | 'MIXEDEXTENT'} , filenum, pagenum [, objectid, indexid, partitionid, allocunitid ] ) ** DBCC fixallocation ('PAGE', 1, 93) ** */ /* ** DBCC flush ('data' | 'log', dbid) ** SELECT db_id('northwind') DBCC flush ('data', 12) ** */ /* ** Clears the stored procedure cache for a specific database. Use this command before testing to ensure that previous stored procedure plans won't negatively affect testing results. ** DBCC flushprocindb (database) ** SELECT db_id('northwind') DBCC flushprocindb (12) -- Northwind ** */ /* ** DBCC forceghostcleanup [ ( { 'dbname' | dbid} ) ] ** */ /* ** DBCC free dll_name (FREE) ** */ /* ** Removes all elements from the procedure cache for all SQL Server databases. ** DBCC freeproccache [ WITH NO_INFOMSGS ] ** DBCC freeproccache ** */ /* ** Flushes the distributed query connection cache used by distributed queries against an instance of Microsoft SQL Server. ** DBCC freesessioncache [WITH NO_INFOMSGS ] ** USE AdventureWorks; GO DBCC FREESESSIONCACHE WITH NO_INFOMSGS; GO ** */ /* ** Releases all unused cache entries from all caches. The SQL Server 2005 Database Engine proactively cleans up unused cache entries in the background to make memory available for current entries. However, you can use this command to manually remove unused entries from all caches. ** DBCC FREESYSTEMCACHE ( 'ALL' ) [WITH { [ MARK_IN_USE_FOR_REMOVAL ] [, [ NO_INFOMSGS ] } ] ** DBCC freesystemcache ('all') ** */ /* ** DBCC freeze_io ( dbname | dbid ) ** DBCC freeze_io (northwind) ** */ /* ** DBCC getvalue (name) ** */ /* ** Returns syntax information for the specified DBCC command. ** DBCC HELP ( 'dbcc_statement' | @dbcc_statement_var | '?' ) [ WITH NO_INFOMSGS ] ** DECLARE @dbcc_stmt sysname; SET @dbcc_stmt = 'CHECKDB'; DBCC HELP (@dbcc_stmt); GO ** */ /* ** DBCC icecapquery ('dbname', stored_proc_name [, #_times_to_icecap (-1 infinite, 0 turns off)]) Use 'dbcc icecapquery (printlist)' to see list of SP's to profile. Use 'dbcc icecapquery (icecapall)' to profile all SP's. ** */ /* ** DBCC incrementinstance (objectname, countername, instancename, value) ** */ /* ** Returns all pages in use by indexes of the specified table. ** DBCC ind ( { 'dbname' | dbid }, { 'objname' | objid }, { indid | 0 | -1 | -2 } ) ** DBCC traceon(3604) DBCC ind ('northwind', 'customers', 2) ** */ /* ** Defragments indexes of the specified table or view. This does not lock tables which permits user to continue working. Rebuilding your indexes does a better job--but does lock tables and impacts your users. This might be considered better than nothing... ** DBCC indexdefrag ({dbid | dbname | 0}, {tableid | tablename}, {indid |indname}) ** DBCC INDEXDEFRAG (AdventureWorks, 'Production.Product', PK_Product_ProductID) GO ** */ /* ** Displays the last statement sent from a client to an instance of Microsoft SQL Server 2005. ** DBCC inputbuffer (spid) ** -- The following example runs DBCC INPUTBUFFER on a second connection while a long -- transaction is running on a previous connection. CREATE TABLE T1 (Col1 int, Col2 char(3)); GO DECLARE @i int; SELECT @i = 0 BEGIN TRAN SELECT @i = 0 WHILE (@i < 100000) BEGIN INSERT INTO T1 VALUES (@i, CAST(@i AS char(3))) SELECT @i = @i + 1 END; COMMIT TRAN; --Start new connection #2. DBCC INPUTBUFFER (52); ** */ /* ** Invalidates the specified in-row text pointer. These pointers are from tables that have the text in row option enabled. SQL Server locks the data row when a user obtains an active text pointer block other users with other needs to the row. To drop the lock use this command. ** DBCC invalidate_textptr (textptr) TextPtr is the sixteen byte varbinary value used to point to the external pages storing the actual data. ** DBCC invalidate_textptr(@ptrval) ** */ /* ** Invalidates in-row text pointers in a table. ** DBCC invalidate_textptr_objid (objid) ** SELECT object_id('') DBCC invalidate_textptr_objid (@objid) ** */ /* ** DBCC iotrace ( { 'dbname' | dbid | 0 | -1 } , { fileid | 0 }, bufsize, [ { numIOs | -1 } [, { timeout (sec) | -1 } [, printopt={ 0 | 1 }]]] ) ** */ /* ** DBCC latch ( address [, 'owners'] [, 'stackdumps']) ** */ /* ** DBCC lock ([{'DUMPTABLE' | 'DUMPSTATS' | 'RESETSTATS' | 'HASH'}] | [{'STALLREPORTTHESHOLD', stallthreshold}]) ** */ /* ** DBCC lockobjectschema ('object_name') ** */ /* ** Returns the transaction log data for the specified database. Option 0 presents minimum information (operation, context, transaction id); this is the default. Option 1 adds flags, tags, row length, description. Option 2 presents very detailed information (object name, index name, page id, slot id). Option 3 shows full information about each operation. Option 4 adds a hex dump of the current transaction log's row. Option -1 adds checkpoint begin, db version max XDESID. ** DBCC log ([dbid[,{0|1|2|3|4}[,['lsn','[0x]x:y:z']|['numrecs',num]|['xdesid','x:y'] |['extent','x:y']|['pageid','x:y']|['objid',{x,'y'}]|['logrecs', {'lop'|op}...]|['output',x,['filename','x']]...]]]) ** DBCC log ('northwind', 2) ** */ /* ** Returns how many VLFs are in the log file and which ones are active. ** DBCC loginfo [({'database_name' | dbid})] ** DBCC loginfo ('AdventureWorks') ** */ /* ** DBCC mapallocunit ** */ /* ** DBCC matview ({'PERSIST' | 'ENDPERSIST' | 'FREE' | 'USE' | 'ENDUSE'}) ** */ /* ** DBCC memobjlist [(memory object)] ** */ /* ** Returns free memory and memory used for the buffer pool. ** DBCC memorymap ** DBCC traceon(3604) DBCC memorymap ** */ /* ** Returns the curent memory status. Used to troubleshoot issues relate to the memory consumption or to specific memory errors. ** DBCC memorystatus ** */ /* ** DBCC memospy ** */ /* ** DBCC memusage ([IDS | NAMES], [Number of rows to output]) ** */ /* ** DBCC metadata ** */ /* ** DBCC monitorevents ('sink' [, 'filter-expression']) ** */ /* ** DBCC movepage ( { 'dbname' | dbid }, src_filenum, src_pagenum [, des_filenum [, des_pagenum [, des_pagenum2 ] ] ] ) WITH NO_INFOMSGS ** */ /* ** DBCC newalloc - please use checkalloc instead ** */ /* ** DBCC no_textptr (table_id , max_inline) ** */ /* ** Displays information about the oldest active transaction and the oldest distributed and nondistributed replicated transactions, if any, within the specified database. Results are displayed only if there is an active transaction or if the database contains replication information. An informational message is displayed if there are no active transactions. ** DBCC opentran [({'dbname'| dbid})] [WITH TABLERESULTS[,NO_INFOMSGS]] ** -- The following example obtains transaction information for the current database. CREATE TABLE T1(Col1 int, Col2 char(3)); GO BEGIN TRAN INSERT INTO T1 VALUES (101, 'abc'); GO DBCC OPENTRAN; ROLLBACK TRAN; GO DROP TABLE T1; GO ** */ /* ** DBCC optimizer_whatif ** */ /* ** Returns the current output buffer in hexadecimal and ASCII format for the specified session_id. ** DBCC outputbuffer (spid) ** DBCC OUTPUTBUFFER (52); ** */ /* ** Returns the contents of a page in various formats. ** DBCC page ( {'dbname' | dbid}, filenum, pagenum [, printopt={0|1|2|3} ][, cache={0|1} ]) ** DBCC traceon(3604) DBCC page (AdventureWorks, 1, 91, 3) ** */ /* ** DBCC perflog ** */ /* ** Returns the network reads and writes. ** DBCC perfmon ** */ /* ** DBCC persiststackhash ** */ /* ** DBCC pglinkage (dbid, startfile, startpg, number, printopt={0|1|2} , targetfile, targetpg, order={1|0}) ** */ /* ** Marks a table to be pinned. This means the SQL Server Database Engine does not flush the pages for the table from memory. ** DBCC pintable (database_id, table_id) ** This functionality was introduced for performance in SQL Server version 6.5. DBCC PINTABLE has highly unwanted side-effects. These include the potential to damage the buffer pool. DBCC PINTABLE is not required and has been removed to prevent additional problems. The syntax for this command still works but does not affect the server. ** */ /* ** Returns procedure buffer headers and stored procedure headers from the procedure cache. ** DBCC procbuf [({'dbname' | dbid}[, {'objname' | objid} [, nbufs[, printopt = { 0 | 1 } ]]] )] ** DBCC procbuf ('northwind', 'Customers', 1, 0) ** */ /* ** Displays information in a table format about the procedure cache. ** DBCC proccache ** */ /* ** Returns the page number pointed to by each row on the specified index page. ** DBCC prtipage (dbname | dbid, objid | objname, indexid | indexname [, partition_number [, level]]). No partition specified uses the first partition. No level specified prints root page. ** DBCC prtipage ('northwind', 'employees', 'LastName', 1) ** */ /* ** Returns information about processes currently connected to the server ** DBCC pss [(uid[, spid[, printopt = { 1 | 0 }]] )] ** DBCC pss (1, 56) ** */ /* ** DBCC readpage ({ dbid, 'dbname' }, fileid, pageid , formatstr [, printopt = { 0 | 1} ]) ** */ /* ** DBCC rebuild_log (dbname [, filename]) ** */ /* ** Rename a column in a table. Use sp_rename or the ALTER TABLE statement as a documented way to accomplish the same task. ** DBCC renamecolumn (object_name, old_name, new_name) ** DBCC renamecolumn (Countries, CName, CountryName) ** */ /* ** DBCC requeststat ** */ /* ** Returns the server's resource, perfmon and ds_config information. Resource show addresses of various data structures used by the server. Perfmon contains master..spt_monitor field info. DS_CONFIG structure contains master.syscurconfigs field information. ** DBCC resource ** */ /* ** DBCC row_lock (dbid, tableid, set) - Not Needed ** */ /* ** DBCC ruleoff ({ rulenum | rulestring } [, { rulenum | rulestring } ]+) ** */ /* ** DBCC ruleon ( rulenum | rulestring } [, { rulenum | rulestring } ]+) ** */ /* ** DBCC semetadata ( objectid | name, index id | name [, partition id ] ) ** select (object_id(N'adventureworks.person.contact')) GO dbcc semetadata (309576141) GO ** */ /* ** DBCC setcpuweight (weight) ** DBCC setcpuweight (100) ** */ /* ** DBCC setinstance (objectname, countername, instancename, value) ** */ /* ** DBCC setioweight (weight) ** DBCC setioweight (100) ** */ /* ** Displays the current distribution statistics for the specified target on the specified table. Examine selectivity to judge the effectiveness of the index. ** DBCC show_statistics ('table_name', 'target_name') ** USE AdventureWorks; GO DBCC SHOW_STATISTICS ('Person.Address', AK_Address_rowguid); GO ** */ /* ** Displays fragmentation information for the data and indexes of the specified table or view. ** DBCC showcontig (table_id | table_name [, index_id | index_name] [WITH FAST, ALL_INDEXES, TABLERESULTS [,ALL_LEVELS]]) ** USE AdventureWorks; GO DBCC SHOWCONTIG ('HumanResources.Employee'); GO ** */ /* ** DBCC showdbaffinity ** DBCC showdbaffinity ** */ /* ** Returns the extent information for database files of the current database. ** DBCC showfilestats [(file_num)] ** DBCC showfilestats ** */ /* ** DBCC showoffrules ** DBCC traceon(3604) DBCC showoffrules DBCC tracepff(3604) ** */ /* ** DBCC showonrules ** DBCC traceon(3604) DBCC showonrules DBCC traceoff(3604) ** */ /* ** DBCC showtableaffinity (table) ** DBCC showtableaffinity (N'AdventureWorks.Person.Contact') ** */ /* ** DOESN'T WORK!!!!!!!!!!!!!!!!!!! ** DBCC showtext ('dbname', {textpointer | {fileid, pageid, slotid [,option]}}) ** SELECT file_id('adventureworks_data') DBCC traceon(3604) DBCC showtext (1, 87, 2) select * from sys.dm_os_buffer_descriptors ** */ /* ** DBCC showweights ** DBCC showweights ** */ /* ** Shrinks the size of the data and log files in the specified database. ** DBCC shrinkdatabase ({dbid | 'dbname'}, [freespace_percentage [, {NOTRUNCATE | TRUNCATEONLY}]]) [ WTIH NO_INFOMSGS ] ** DBCC SHRINKDATABASE (UserDB, 10); GO ** */ /* ** DBCC shrinkdb ** */ /* ** Shrinks the size of the specified data or log file for the current database or empties a file by moving the data from the specified file to other files in the same filegroup, allowing the file to be removed from the database. You can shrink a file to a size that is less than the size specified when it was created. This resets the minimum file size to the new value. ** DBCC shrinkfile ({fileid | 'filename'}, [compress_size [, {NOTRUNCATE | TRUNCATEONLY | EMPTYFILE}]]) ** USE AdventureWorks; GO -- Truncate the log by changing the database recovery model to SIMPLE. ALTER DATABASE AdventureWorks SET RECOVERY SIMPLE; GO -- Shrink the truncated log file to 1 MB. DBCC SHRINKFILE (AdventureWorks_Log, 1); GO -- Reset the database recovery model. ALTER DATABASE AdventureWorks SET RECOVERY FULL; GO** */ /* ** Returns three different values that can sometimes be ueful when you want to find out how well caching is being performed on ad-hoc and prepared Transact-SQL statements ** DBCC sqlmgrstats ** DBCC sqlmgrstats ** */ /* ** Provides transaction log space usage statistics for all databases. It can also be used to reset wait and latch statistics. ** DBCC SQLPERF ( [ LOGSPACE ] | [ 'sys.dm_os_latch_stats' , CLEAR ] | [ 'sys.dm_os_wait_stats' , CLEAR ] ) [WITH NO_INFOMSGS ] ** DBCC SQLPERF(LOGSPACE); DBCC SQLPERF(UMSSTATS); DBCC SQLPERF(IOSTATS); DBCC SQLPERF(WAITSTATS); DBCC SQLPERF(RASTATS); DBCC SQLPERF(THREADS); GO ** */ /* ** DBCC stackdump [( {uid[, spid[, ecid]} | {threadId, 'THREADID'}] )] ** */ /* ** Returns the data pages structure. As compared to DBCC Page, this command returns information about all data pages for a viewed table, not only for a particular number. ** DBCC tab ( dbid, objid ) ** SELECT object_id(N'Northwind.dbo.Employees') DBCC tab (12, 2073058421) ** */ /* ** DBCC tape_control {'query' | 'release'}[,('.tape')] ** */ /* ** DBCC tec [( uid[, spid[, ecid]] )] ** */ /* ** DBCC textall [({'database_name'|database_id}[, 'FULL' | FAST] )] ** */ /* ** DBCC textalloc ({'table_name'|table_id}[, 'FULL' | FAST]) ** */ /* ** DBCC thaw_io (db) ** */ /* ** Disables the specified trace flags. ** DBCC traceoff [( tracenum [, tracenum ... ] )] ** DBCC TRACEOFF (3205); GO ** */ /* ** Enables the specified trace flags. ** DBCC traceon [( tracenum [, tracenum ... ] )] ** DBCC TRACEON (3205, 260, -1); GO ** */ /* ** Displays the status of trace flags. ** DBCC tracestatus (trace# [, ...trace#]) ** DBCC TRACESTATUS (2528, 3205); GO ** */ /* ** Marks a table as unpinned. After a table is marked as unpinned, the table pages in the buffer cache can be flushed. ** DBCC unpintable (dbid, table_id) ** This functionality was introduced for performance in Microsoft SQL Server version 6.5. DBCC UNPINTABLE has highly unwanted side-effects. These include the potential to damage the buffer pool. DBCC UNPINTABLE is not required and has been removed to prevent additional problems. The syntax for this command still works but does not affect the server. ** */ /* ** Reports and corrects pages and row count inaccuracies in the catalog views. These inaccuracies may cause incorrect space usage reports returned by the sp_spaceused system stored procedure. In SQL Server 2005, these values are always maintained correctly. Databases created on SQL Server 2005 should never experience incorrect counts, however, databases upgraded to SQL Server 2005 may contain invalid counts. Run DBCC UPDATEUSAGE after upgrading to SQL Server 2005 to correct any invalid counts. ** DBCC updateusage ({'database_name'| 0} [, 'table_name' [, index_id]]) [WITH [NO_INFOMSGS] [,] COUNT_ROWS] ** USE AdventureWorks; GO DBCC UPDATEUSAGE ('AdventureWorks') WITH NO_INFOMSGS; GO ** */ /* ** DBCC upgradedb (db) ** */ /* ** DBCC usagegovernor (command, value) ** */ /* ** DBCC useplan [(number_of_plan)] ** */ /* ** Returns the SET options active (set) for the current connection. ** DBCC useroptions DBCC wakeup (spid) ** DBCC USEROPTIONS; ** */ /* ** DBCC writepage ({ dbid, 'dbname' }, fileid, pageid, offset, length, data) ** */