得到的音符,SQL主键,并在MSSQL表结构方面的信息

1、MSSQL2000
复制代码代码如下所示:
选择
表名=情况时,a.colorder = 1然后d.name别人结束,
表格显示的情况时,a.colorder = 1 =空(f.value,'')别人结束,
场序数= a.colorder,
字段名称= a.name,
ID =情况时,columnproperty(张,a.name,'isidentity)= 1然后''else结束B.,
当存在主键为例(选择1中,'pk'and parent_obj xtype = =张和名称)(
选择的名字从哪里indid sysindexes中(
选择indid从sysindexkeys id是张和给= a.colid)))' '其他'结束B.,
类型= b.name,
字节数= a.length,
长度= columnproperty(张,a.name,'precision),
小数位数=空(columnproperty(张,a.name,规模),0)。
当a.isnullable = 1然后允许空=案end'else '滴答,
默认值为空(e.text,),
描述字段为空(G. {value},)

列一个
左连接
systypes中存在B

a.xusertype = b.xusertype
内部联接
sysobjects D

张= d.id和d.xtype = 'u'and d.name <> 'dtproperties
左连接
syscomments E

a.cdefault = e.id
左连接
sysproperties G

张g.id和g.smallid a.colid = =
左连接
sysproperties F

d.id = f.id和f.smallid = 0
哪里
d.name = 'fi_dept --如果只指定表的查询,添加这个条件
顺序

A.id,a.colorder


2、MSSQL2005

使用测试——数据库

2005实现了字段属性统计(2000在系统表sysproperties描述表,字段不存在,2005是由sys.extended_properties观取代)
选择
{姓名} = c.name表,
{说明} =空表(F. {value},),
{姓名} = a.name柱,
{ } = a.column_id序列号,
{ } = = 1时is_identity标志'嘀'其他'结束,
{主要} =案件时存在(选择1 sys.objects哪里parent_object_id = a.object_id类型= n'pk'and名称)
(选择的名字从sys.indexes index_id在哪里
(选择从哪里indid sysindexkeys给= a.column_id))))
然后‘滴答'结束,
{类型} = b.name,
{ } =字节数时A. { max_length } = - 1、B的名字!= 'xml'then'max / 2G
当b.name = 'xml'then 2 ^ 31-1字节/ 2G
别的RTrim(A. { max_length })结束,
{长} = columnproperty(a.object_id,姓名,'precision),
{小数} =空(columnproperty(a.object_id、名字、规模),0),
{ } =情况时,a.is_nullable = 1然后是空的'嘀'其他'结束,
{说明} =空(E. {value},),
{默认值} =空(d.text,)

sys.columns一
左连接
在a.user_type_id = b.user_type_id Sys.types B
内部联接
sys.objects C对a.object_id = c.object_id和c.type = U
左连接
syscomments D对a.default_object_id = d.id
左连接
sys.extended_properties E对e.major_id = c.object_id和e.minor_id = a.column_id和课= 1
左连接
sys.extended_properties F对f.major_id = c.object_id和f.minor_id = 0和f.class = 1
{代码}
结果uff1a