在 SQL Server 2008 上创建表的 SQL 注释 [英] SQL Comments on Create Table on SQL Server 2008

查看:40
本文介绍了在 SQL Server 2008 上创建表的 SQL 注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 SQL Server 2008 中创建一些非常大的表,虽然我有 SQL Server Management Studio,但我想在创建表时注释这些表和列.我该怎么做呢?

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
)

我在数据类型后尝试了 COMMENT'Expiration Date for the Adult CPR' 和 COMMENT='Expiration Date for the Adult CPR',SQL Server 给我一个错误.

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.

推荐答案

您可以通过创建所谓的扩展属性对表和列进行注释.您可以在表级别和列级别放置扩展属性.这可以通过 T-SQL 或 SSMS 完成.

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.

例如,在 T-SQL 中,它看起来像这样:

For example, in T-SQL it looks something like this:

sp_addextendedproperty 'BackColor', 'Red', 'user', '<schema name>', 'table', '<table name', 'column', '<column name>'.

您可以在此处

这篇关于在 SQL Server 2008 上创建表的 SQL 注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆