Você está na página 1de 3

How can I set the database to single user mode and restrict the access to dbo use only?

Answer: In SQL Server 2000, a database cannot be in single-user mode with dbo use only. Instead, the following alternative options are available by using the ALTER DATABASE command:

ALTER DATABASE database SET SINGLE_USER. This command restricts access to the database to only one user at a time.

ALTER DATABASE database SET RESTRICTED_USER. This command restricts access to the database to only members of the db_owner, dbcreator, or sysadmin roles.

ALTER DATABASE database SET MULTI_USER. This command returns access to the database to its normal operating state.

How can I qualify a named instance in a linked server query? Answer: You must use square brackets around the multi-instance linked server name in the four part query. For example: SELECT * FROM [myServer\sql80].northwind.dbo.customers Maintenance Statements DBCC DBREINDEX DBCC DBREPAIR DBCC INDEXDEFRAG DBCC SHRINKDATABASE DBCC SHRINKFILE DBCC UPDATEUSAGE Miscellaneous Statements DBCC dllname (FREE) DBCC HELP DBCC PINTABLE DBCC ROWLOCK DBCC TRACEOFF DBCC TRACEON DBCC UNPINTABLE

Status Statements DBCC INPUTBUFFER DBCC OPENTRAN DBCC OUTPUTBUFFER DBCC PROCCACHE DBCC SHOWCONTIG DBCC SHOW_STATISTICS DBCC SQLPERF DBCC TRACESTATUS DBCC USEROPTIONS Validation Statements DBCC CHECKALLOC DBCC CHECKCATALOG DBCC CHECKCONSTRAINTS DBCC CHECKDB DBCC CHECKFILEGROUP DBCC CHECKIDENT DBCC CHECKTABLE DBCC NEWALLOC

DBCC SHRINKDATABASE
Shrinks the size of the data files in the specified database.
Syntax

DBCC SHRINKDATABASE ( database_name [ , target_percent ] [ , { NOTRUNCATE | TRUNCATEONLY } ] )

DBCC SHRINKFILE
Shrinks the size of the specified data file or log file for the related database.
Syntax

DBCC SHRINKFILE ( { file_name | file_id } { [ , target_size ]

| [ , { EMPTYFILE | NOTRUNCATE | TRUNCATEONLY } ] } )


Recommendations for Good DBCC Performance

Run CHECKDB when the system usage is low. Be sure that you are not performing other disk I/O operations, such as disk backups. Place tempdb on a separate disk system or a fast disk subsystem. Allow enough room for tempdb to expand on the drive. Use DBCC with ESTIMATE ONLY to estimate how much space will be needed for tempdb. Avoid running CPU-intensive queries or batch jobs. Reduce active transactions while a DBCC command is running. Use the NO_INFOMSGS option to reduce processing and tempdb usage significantly.

Consider using DBCC CHECKDB with the PHYSICAL_ONLY option to check the physical structure of the page and record headers. This operation performs a quick check if hardware-induced errors are suspect.

Você também pode gostar