- Rewrite the content of PROPERTY_NAME
- Select database
- Run SQL
DECLARE @TABLE_NAME VARCHAR(255) DECLARE @SQL VARCHAR(8000) DECLARE @PROPERTY_NAME VARCHAR(255) SET @PROPERTY_NAME = 'Description' DECLARE C_TABLE CURSOR FOR SELECT name FROM sysobjects WHERE OBJECTPROPERTY(id, N'IsUserTable') = 1 AND status >= 0 ORDER BY name OPEN C_TABLE FETCH NEXT FROM C_TABLE INTO @TABLE_NAME WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM C_TABLE INTO @TABLE_NAME PRINT @TABLE_NAME SET @SQL = ' EXEC sys.sp_addextendedproperty @name=N''' + @PROPERTY_NAME + ''', @value=N'''' , @level0type=N''SCHEMA'', @level0name=N''dbo'', @level1type=N''TABLE'', @level1name=N''' + @TABLE_NAME + '''' EXEC (@SQL) END CLOSE C_TABLE
No comments:
Post a Comment