首页 > 代码库 > 查询数据库字段

查询数据库字段

select AA.columnname,AA.tablename ,AA.typename,AA.max_length,AA.precision,AA.scale ,BB.remark from (select a.name as columnname,b.name tablename ,c.name typename,a.max_length,a.precision,a.scalefrom sys.columns a,sys.objects b,sys.types cwhere a.object_id=b.object_id and a.user_type_id=c.user_type_idand b.type=u ) AA LEFT JOIN(select a.name as columnname,b.name tablename ,c.name typename,a.max_length,a.precision,a.scale,cast(isnull(e.[value],‘‘) as nvarchar(100)) as remarkfrom sys.columns a,sys.objects b,sys.types c,sys.extended_properties ewhere a.object_id=b.object_id and a.user_type_id=c.user_type_idand b.type=uand  e.major_id=b.object_id and e.minor_id=a.column_id and e.class=1) BB  on AA.columnname=BB.columnname AND AA.tablename=BB.tablename ORDER BY AA.tablename
select a.name, cast(isnull(e.[value],‘‘) as nvarchar(100)) as remark from  sys.columns a inner join sys.objects c on a.object_id=c.object_id and c.type=uleft join sys.extended_properties e on e.major_id=c.object_id and e.minor_id=a.column_id and e.class=1 where c.name=AssistEngineer
select a.name as columnname,b.name tablename ,c.name typename,a.max_length,a.precision,a.scale,cast(isnull(e.[value],‘‘) as nvarchar(100)) as remarkfrom sys.columns a,sys.objects b,sys.types c,sys.extended_properties ewhere a.object_id=b.object_id and a.user_type_id=c.user_type_idand b.type=uand  e.major_id=b.object_id and e.minor_id=a.column_id and e.class=1--and c.name in(varchar,nvarchar,char,nchar,text,ntext)--and object_name(a.object_id)<>torder by b.name

 

查询数据库字段