Friday, February 24, 2012

Include Comments in SQL Script

Hi,

When I generate SQL Script for my database, I wish to include the comments added against each column in the script. But there is no option available where I can specify to include "COMMENTS".

Please suggest.

Regards,

Sudhir Chawla

you can add custom comments by using this

-- two dashes

sql server scripts genarator has no comments option

you have to comment the scripts by yourself

|||

Or you can wrap your scripts in block comments

/*
If you have multiple
lines to comment
then you can use block comments
*/

|||

Actually,

When you create table and add columns, at that time there is a "DESCRIPTION" field, where we can specify the comments for that column. So how do I include these column level comments to be present in my script. I can add my own comments using -- or /* adjkasjd */, but I wish to include column level comments in my script.

Thanks for your advice.

Regards,

Sudhir

|||

I believe the DESCRIPTION field is actually an extended property. If you are using the Script Wizard (right click on the database, select check Tasks > Generate Scripts) to create your scripts, you can check the "Script Extended Properties" checkbox on the Script Options page to get the description scripted.

If you are using the Script context menu in Object Explorer to create your script, you will have to wait until SP2 to get this option, which will be exposed in a new scripting options dialog (e.g. Tools > Options > Scripting in the main menu bar).

Hope this helps,
Steve

No comments:

Post a Comment