SQL Server 2005:
create proc [dbo].[LookCol]
@TableName nvarchar(50)
as
begin
select c.ColID, c.name ColName, t.name TypeName, c.Length,c.IsNullable, p.value Note
from syscolumns c
inner join sysobjects o on o.id=c.id
inner join systypes t on t.xusertype = c.xtype
left join sys.extended_properties p on c.id=p.major_id and c.colid = p.minor_id
where o.name=@TableName
order by colid
end
SQL Server 2000:
create proc [dbo].[LookCol]
@TableName nvarchar(50)
as
begin
select
c.ColID,
c.name ColName,
t.name TypeName,
c.Length,
c.IsNullable,
p.value Note
from
syscolumns c
inner join sysobjects o on o.id=c.id
inner join systypes t on t.xusertype = c.xtype
left join sysproperties p on c.id=p.id and c.colid = p.smallid
where o.name=@TableName
order by colid
end
转载于:https://www.cnblogs.com/wuhen/articles/1615175.html