I need to create some pretty big tables in SQL Server 2008, while I do have SQL Server Management Studio, I would like to comment the tables and the columns when I create the table. How do I do this?
Example of the query I am running:
CREATE TABLE cert_Certifications
(
certificationID int PRIMARY KEY IDENTITY,
profileID int,
cprAdultExp datetime null
)
I've tried COMMENT'Expiration Date for the Adult CPR' and COMMENT='Expiration Date for the Adult CPR' after the data type, and SQL Server is giving me an error.
You can put comments on both tables and columns by creating what are called Extended Properties. You can put extended properties at both the table level and column level. This can be done via T-SQL or SSMS.
For example, in T-SQL it looks something like this:
You can read more about it here
use this sql command
Create table TABLE NAME (ATTRIBUTE NAME (ATTRIBUTE SIZE))
// bothcreate
andtable
are KeywordsThis is what I use
You need to use the stored procedure called sp_addextendedproperty to add comments to columns/tables in Sql Server.
I prefer the GUI when desinging tables because I can visualize the layout better. In the GUI designer one can add a description for the table and columns in the properties window as shown in the image below
There are good answers in this post. Adding that the value 'MS_Description' could be other thing. For example, we can use 'SourceDescription' for details about the source the data, 'TableDescription' for table and 'ColumnDescription' for each column on table.
Example: