How to copy a table with it table comment and column comment ?

Database

How to copy a table with it table comment and column comment ?

Hi,

I can copy a table with no data or with data ,
but can not copy it table comment and column comment to the new table, right?
or there have alternative to solve it.

Thanks and regards.
Hawk
2 REPLIES
Enthusiast

Re: How to copy a table with it table comment and column comment ?

After copying the table with or with out data you can write an SQL statement against DBC.Tables and DBC.Columns to pull the Comment and construct the COMMENT TABLE or COMMENT COLUMN statements to be run against the new table.

For example:

SELECT 'COMMENT MyDB.MyNewTable AS ' || T.Comment || ';'
FROM DBC.Tables T
WHERE DatabaseName = 'MyOriginalDB'
AND TableName = 'MyOriginalTable';

Re: How to copy a table with it table comment and column comment ?

Thanks, robpaller, i can retrive comment and update new table manually.

Thanks and Regards,
Hawk