--查询大数据表
select top 100 name as indexname,object_name(id) as tablename,used,rows,indid from sysindexes order by rows desc
--修改、新增表的字段
alter table <表名> alter column <字段名> 新类型名(长度)
alter table <表名> add <字段名> 字段类型(长度)
--所有触发器名称
select name from sysobjects where xtype='TR'
--所有存储过程
select name from sysobjects where xtype='P'
--查询存储过程的内容
sp_helptext UP_NightAudit_RtoN
--所有视图
select name from sysobjects where xtype='V'
--所有表
select name from sysobjects where xtype='U'
--查询表字段的字段说明
exec UP_DataDictionary '表名'
--全部禁用:
Alter table t1 disable trigger all;
--全部生效:
Alter table t1 enable trigger all;
--单个禁用:
Alter table t1 disable trigger 触发器名;
--查出指定TR的内容:
sp_helptext 't_test'
--查出所有名称与内容:
select b.name as '名称',a.text as '内容',case xtype when 'p' then '存储过程' else '触发器 ' end as '类型'
from syscomments a,sysobjects b where object_id(b.name)=a.id and b.xtype in( 'P','TR') and b.status> =0 order by '类型'
--查出某表中所有字段名与字段类型:
select a.name as [column],b.name as type
from syscolumns a,systypes b
where a.id=object_id('tb_Mainbusiness') and a.xtype=b.xtype