SqlServer2008R2常用语句
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SqlServer2008R2常用语句相关的知识,希望对你有一定的参考价值。
1.查询表中的RID
RID=RowID=(fileID:pageID:slotID)
SELECT sys.fn_PhysLocFormatter(%%physloc%%) AS rid,* FROM person;
2.开启DBCC命令语法
(1).开启
DBCC TRACEON(2588)
(2).帮助命令
DBCC HELP(IND)
3.开启导出数据页语法
(1).开启
DBCC TRACEON(3604);
(2).导出数据页
DBCC PAGE(test,1,262,2);
4.索引的统计信息
DBCC SHOW_STATISTICS(test1,idx_test1);
5.查询锁
SELECT *
FROM sys.sysprocesses
WHERE spid IN (63,60);
SELECT request_session_id, resource_type,
request_status, request_mode,
resource_description, object_name(p.object_id) as object_name,p.index_id
FROM sys.dm_tran_locks left join sys.partitions p
on sys.dm_tran_locks.resource_associated_entity_id = p.hobt_id
WHERE request_session_id IN (63,60);
6.查询解析树/执行计划
SELECT CP.usecounts AS CountOfQueryExecution ,
CP.cacheobjtype AS CacheObjectType ,
CP.objtype AS ObjectType ,
ST.text AS QueryText
FROM sys.dm_exec_cached_plans AS CP
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS ST
WHERE CP.usecounts > 0;
以上是关于SqlServer2008R2常用语句的主要内容,如果未能解决你的问题,请参考以下文章
sqlserver 2008R2新建数据库时报错,提示无法获得数据库"model"上的排它锁
转换 SQL Server 2008 R2 和 2012 之间的差异