Some usefull SQL Commands

If you are a SQL Server administrator or just working with it, these commands would be use full for you.

ALTER INDEX

Modifies an existing table or view index (relational or XML) by disabling, rebuilding, or reorganizing the index; or by setting options on the index.

DBCC DBREINDEX

Rebuilds one or more indexes for a table in the specified database.

This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER INDEX instead.

DBCC INDEXDEFRAG

Defragments indexes of the specified table or view.This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER INDEX instead.

DBCC SHOWCONTIG

Displays defragmentation information for data and indexes of a specified table.

DBCC SHRINKDATABASE

Shrinks the size of the data and log files in the specified database.

DBCC SHRINKFILE

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.

KILL

Terminates a user proces. It uses the spid as an identifier, and can therefore with benifit be used in combination with sp_who2.Notice – if the specified session ID has a lot of work to undo, the KILL statement may take some time to complete, particularly when it involves rolling back a long transaction.

SP_LOCK

Displays active locks.

SP_SPACEUSED

Displays the number of rows, disk space reserved, and disk space used by a table, indexed view, or SQL Server 2005 Service Broker queue in the current database, or displays the disk space reserved and used by the whole database.

SP_WHO

Displays information about current users and processes.

SP_WHO2

Displays information about current users and processes. It is a function similar to sp_who. The big difference is that it also displays CPU usages and DiskIO. So if possible, always use this command.

You can leave a response, or trackback from your own site.

Leave a Reply


four − 1 =