2009.05.14 18:55
보통 적으로 많이 사용하는 쿼리들 입니다.
--System table Query
select * from sysobjects where xtype='u'
--Table size
select table_name = convert(varchar(30), min(o.name)), table_size = ltrim(str(sum(reserved) *8192/1024,15,0) + 'kb'),crdate,refdate
from sysindexes i inner join sysobjects o on (o.id = i.id)
where i.indid in (0,1,255) and o.xtype = 'U'
group by i.id,crdate, refdate
order by refdate desc
--Table PK 기본키
select name from sysobjects where xtype ='pk'
--Table name
select x.id, substring(y.name,1,30) as [table], substring(x.name,1,30)
as field_name, substring(type_name(x.xusertype),1,20) as type,
convert(int,x.length) as length
from syscolumns x inner join
sysobjects y on x.id = y.id
where (y.type='U')
order by x.id, y.name, x.colid
-- Columns
select * from syscolumns
--Table Field
sp_helpindex s_member_tbl
--# 참고 Sysobjects
select * from sysobjects