--添加或者更新表说明 ALTER PROC [dbo].[AddOrUpdateTableComment] ( @tableName sysname , @comment NVARCHAR(50) ) AS ; IF EXISTS ( SELECT * FROM syscolumns a INNER JOIN sysobjects d ON a.id = d.id AND d.xtype = 'U' AND d.name <> 'sys.extended_properties' LEFT JOIN sys.extended_properties f ON a.id = f.major_id AND f.minor_id = 0 WHERE d.name = @tableName AND a.colorder = 1 AND f.value IS NOT NULL ) BEGIN EXECUTE sys.sp_updateextendedproperty N'MS_Description', @comment, N'SCHEMA', N'dbo', N'TABLE', @tableName; END; ELSE BEGIN EXEC sp_addextendedproperty 'MS_Description', @comment, 'user', dbo, 'table', @tableName; END;