--查看表的索引使用情况SELECT TOP 1000o.name AS 表名, i.name AS 索引名, i.index_id AS 索引id, dm_ius.user_seeks AS 搜索次数, dm_ius.user_scans AS 扫描次数, dm_ius.user_lookups AS 查找次数, dm_ius.user_updates AS 更新次数, p.TableRows as 表行数, 'DROP INDEX ' + QUOTENAME(i.name)+ ' ON '…
SELECT SERVERPROPERTY('ServerName') AS ServerName SELECT SERVERPROPERTY('BuildClrVersion') AS BuildClrVersion SELECT SERVERPROPERTY('Collation') AS Collation SELECT SERVERPROPERTY('CollationID') AS CollationID SELECT SERVERPROPERTY('ComparisonStyle')…
经常会需要分析SQLSERVER的阻塞情况,尤其是某些SQL操作异常缓慢从而怀疑是有人在搞事情的情况下.网上有许多一模一样的帖子,是关于sp_who_lock这个存储过程的,然而,网上流传的这个是略有问题的(被阻塞的SQL输出有误),为此改造了一下实现,顺便优化了一下输出结构: CREATE PROCEDURE [dbo].[sp_who_lock] AS BEGIN DECLARE @spid INT , @bl INT , @intTransactionCountOnEntry INT ,…
查看索引: select * FROM information_schema.TABLE_CONSTRAINTS ; select * FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_NAME=‘table_name’ ; 查看表信息: show create table table_name; 查看触发器: SELECT * FROM information_schema.`TRIGGERS`;…