SQL 2005クエリテーブル構造のSQL文を共有する
1932 ワード
SELECT
(case when a.colorder=1 then d.name else '' end) as ,-- syscolumns( ) a sysobjects d
a.colorder as ,
a.name as ,
(case when COLUMNPROPERTY( a.id,a.name, 'IsIdentity' )=1 then '√' else '' end) as , -- IsIdentity ,IsIdentity :0、1
(case when (SELECT count(*) FROM sysobjects--
WHERE (name in
(SELECT name FROM sysindexes
WHERE (id = a.id) AND (indid in
(SELECT indid FROM sysindexkeys
WHERE (id = a.id) AND (colid in
(SELECT colid FROM syscolumns
WHERE (id = a.id) AND (name = a.name))
)))))
AND (xtype = 'PK' ))>0 then '√' else '' end) as ,-- END
b.name as , --systypes b
a.length as ,
COLUMNPROPERTY(a.id,a.name,'PRECISION' ) as ,
isnull(COLUMNPROPERTY(a.id,a.name,'Scale' ),0) as ,
(case when a.isnullable=1 then '√' else '' end) as ,
isnull(e.text,'' ) as , --syscomments e
isnull(g.[value],'' ) AS --sys.extended_properties g ( )
FROM syscolumns a left join systypes b
on a.xtype=b.xusertype
inner join sysobjects d
on a.id=d.id and d.xtype='U' and d.name<> 'dtproperties'
left join syscomments e
on a.cdefault=e.id
left join sys.extended_properties g
on a.id=g.major_id AND a.colid = g.minor_id
where d.name='systempara' --
order by a.id,a.colorder