SELECT b.name as TableName,a.name ColumnName,c.name as DataType,p.value as Description,a.max_length as MaxLength
,(case a.is_identity when 1 then 'True' else 'False' end) as [Identity]
,(case a.is_nullable when 1 then 'True' else 'False' end) as [IsNull]
,(case k.type when 'PK' then 'True' else 'False' end) as [IsKey]
FROM sys.objects b
INNER JOIN sys.columns a ON a.object_id = b.object_id
LEFT JOIN sys.types c ON a.system_type_id=c.user_type_id
LEFT JOIN sys.extended_properties p ON p.major_id = a.object_id AND p.minor_id = a.column_id and p.name = 'MS_Description'
left join INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE scc on scc.TABLE_NAME=b.name and scc.COLUMN_NAME=a.name
left join sys.objects k on k.name=scc.CONSTRAINT_NAME and k.type='PK'
WHERE b.type='U' and a.name='ID'

相关文章:

  • 2021-08-15
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2021-07-04
  • 2022-01-06
猜你喜欢
  • 2022-03-05
  • 2022-02-18
  • 2021-06-02
  • 2022-03-09
  • 2021-11-07
  • 2021-04-18
  • 2021-09-29
相关资源
相似解决方案