1.原脚本,sp_addextendedproperty的0级别类型写的是user,这个类型在高版本中已经删除,无法使用,应该切换成SCHEMA
[if exists(select 1 from sys.extended_properties p where p.major_id = object_id('[%QUALIFIER%]%TABLE%') and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = %.q:COLUMN%) ) begin [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% :declare @CurrentUser sysname select @CurrentUser = user_name() [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% ] end ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]]'user', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% :select @CurrentUser = user_name() [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]]'user', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% ]
2.PowerDesigner工作空间-新建-Physica Data Model;右键PhysicalDataModel_1,选择属性-DBMS-打开右边的Properties-Script-Column-ColumnComment
3.修改值为
[if exists(select 1 from sys.extended_properties p where p.major_id = object_id('[%QUALIFIER%]%TABLE%') and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = %.q:COLUMN%) ) begin [%OWNER%?[.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]'SCHEMA', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% :declare @CurrentUser sysname select @CurrentUser = 'dbo' [.O:[execute ][exec ]]sp_dropextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]'SCHEMA', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% ] end ][%OWNER%?[.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]]'SCHEMA', [%R%?[N]]%.q:OWNER%, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% :select @CurrentUser = 'dbo' [.O:[execute ][exec ]]sp_addextendedproperty [%R%?[N]]'MS_Description', [%R%?[N]]%.q:COMMENT%, [%R%?[N]]'SCHEMA', [%R%?[N]]@CurrentUser, [%R%?[N]]'table', [%R%?[N]]%.q:TABLE%, [%R%?[N]]'column', [%R%?[N]]%.q:COLUMN% ]
4.双击设计的表,查看preview就可以拿到能执行的sql了
标签:column,%.,COLUMN%,SqlServer,表列,PowerDesigner,R%,TABLE%,id From: https://www.cnblogs.com/wenthing/p/17912903.html