manglu

sqlserver 查询表结构

 

 

 

select
col.name as ColumnName,
col.max_length as DataLength,
col.is_nullable as IsNullable,
t.name as DataType,
ep.value as Description,
(
select top 1 ind.is_primary_key from sys.index_columns ic
left join sys.indexes ind
on ic.object_id=ind.object_id
and ic.index_id=ind.index_id
and ind.name like \'PK_%\'
where ic.object_id=obj.object_id
and ic.column_id=col.column_id
) as IsPrimaryKey
from sys.objects obj
inner join sys.columns col
on obj.object_id=col.object_id
left join sys.types t
on t.user_type_id=col.user_type_id
left join sys.extended_properties ep
on ep.major_id=obj.object_id
and ep.minor_id=col.column_id
and ep.name=\'MS_Description\'
where obj.name=\'userinfo\' --要查询的表名称

分类:

技术点:

相关文章:

  • 2022-02-26
  • 2021-10-12
  • 2022-01-03
  • 2021-12-07
  • 2022-03-07
猜你喜欢
  • 2022-12-23
  • 2021-08-15
  • 2021-11-21
  • 2021-11-07
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案