set statistics io on
select count(*) from zy_inactpatient
set statistics io off
返回表的空间使用情况
sp_spaceused zy_inactpatient
返回统计的执行时间
set statistics time on
set statistics time on
用文本的方式显示执行计划
set showplan_text on
set showplan_text off
set nocount on
set nocount off
返回有关语句的执行方式和预计使用的资源
set showplan_all on
set showplan_all off
seek优于scan
通常情况下连接查询优于子查询
Lecco SQL Expert Pro for SQL Server
Quest公司的Quest Central工具中的SQL Tuning 工具
//收缩数据库到10%
dbcc shrinkdatabase(his_mj,10)
//首先截断事务日志,然后收缩日志文件
backup log his_mj with truncate only
dbcc shinkfile(his_mj_log,1)