CREATE PROCEDURE [dbo].[TablePrint]
@TableName VARCHAR(50)
AS
SELECT Sysobjects.name AS [数据表名], syscolumns.name AS [列名],
systypes.name AS [数据类型], syscolumns.length AS [字段长度],
sys.extended_properties.[value] AS [字段描述], syscomments.text AS
[默认值],syscolumns.isnullable AS [是否允许空值] FROM syscolumns
INNER JOIN systypes
ON syscolumns.xtype = systypes.xtype
LEFT JOIN sysobjects ON syscolumns.id = sysobjects.id
LEFT OUTER JOIN sys.extended_properties ON
( sys.extended_properties.minor_id = syscolumns.colid
AND sys.extended_properties.major_id = syscolumns.id)
LEFT OUTER JOIN syscomments ON syscolumns.cdefault = syscomments.id
WHERE syscolumns.id IN
(SELECT id FROM SYSOBJECTS WHERE xtype = 'U' AND NAME = @TableName) AND (systypes.name <> 'sysname')
ORDER BY syscolumns.colid
GO
@TableName VARCHAR(50)
AS
SELECT Sysobjects.name AS [数据表名], syscolumns.name AS [列名],
systypes.name AS [数据类型], syscolumns.length AS [字段长度],
sys.extended_properties.[value] AS [字段描述], syscomments.text AS
[默认值],syscolumns.isnullable AS [是否允许空值] FROM syscolumns
INNER JOIN systypes
ON syscolumns.xtype = systypes.xtype
LEFT JOIN sysobjects ON syscolumns.id = sysobjects.id
LEFT OUTER JOIN sys.extended_properties ON
( sys.extended_properties.minor_id = syscolumns.colid
AND sys.extended_properties.major_id = syscolumns.id)
LEFT OUTER JOIN syscomments ON syscolumns.cdefault = syscomments.id
WHERE syscolumns.id IN
(SELECT id FROM SYSOBJECTS WHERE xtype = 'U' AND NAME = @TableName) AND (systypes.name <> 'sysname')
ORDER BY syscolumns.colid
GO