快速查询数据库表字段名,存储过程

时间:2022-01-06 07:11:01

ALTER PROC [dbo].[sp_help_table]
@tableName NVARCHAR(50)
AS
BEGIN
SELECT a.colorder 字段序号,a.name 字段名,b.name 字段类型,b.length AS 字段长度,g.[value] AS 字段说明
FROM syscolumns a left join systypes b
on a.xtype=b.xusertype
inner join sysobjects d
on a.id=d.id and d.xtype=’U’ and d.name<>’dtproperties’
left join sys.extended_properties g
on a.id=g.major_id AND a.colid = g.minor_id
WHERE d.[name] =@tableName
order by a.id,a.colorder
END