Created
July 4, 2012 06:23
-
-
Save hafuu/3045709 to your computer and use it in GitHub Desktop.
コメントをテーブル名、カラム名にする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| tables.name | |
| , columns.name | |
| , table_comments.value | |
| , column_comments.value | |
| , 'EXEC sp_rename ''' + CONVERT(varchar, tables.name) + '.' + CONVERT(varchar, columns.name) + ''', ''' + CONVERT(varchar, column_comments.value) + ''' , ''COLUMN'';' | |
| FROM | |
| sys.tables AS tables | |
| INNER JOIN sys.columns AS columns ON | |
| tables.object_id = columns.object_id | |
| INNER JOIN sys.extended_properties AS table_comments ON | |
| tables.object_id = table_comments.major_id | |
| AND table_comments.minor_id = 0 | |
| INNER JOIN sys.extended_properties AS column_comments ON | |
| columns.object_id = column_comments.major_id | |
| AND columns.column_id = column_comments.minor_id | |
| ORDER BY | |
| tables.object_id | |
| , columns.column_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| tables.name | |
| , table_comments.value | |
| , 'EXEC sp_rename ''' + CONVERT(varchar, tables.name) + ''', ''' + CONVERT(varchar, table_comments.value) + ''';' | |
| FROM | |
| sys.tables AS tables | |
| INNER JOIN sys.extended_properties AS table_comments ON | |
| tables.object_id = table_comments.major_id | |
| AND table_comments.minor_id = 0 | |
| ORDER BY | |
| tables.object_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment