2012-01-26 103 views

回答

22

在創建SQL Server Management Studio中的新表,請參考下面提到的將描述添加到列中的屏幕截圖。

enter image description here

另一種方式來做到這一點編程

EXEC sp_updateextendedproperty 
@name = N'MS_Description', @value = 'Your description', 
@level0type = N'Schema', @level0name = dbo, 
@level1type = N'Table', @level1name = Your Table Name, 
@level2type = N'Column', @level2name = Yuur Column Name; 
+1

而不是使用用戶界面,我會知道SQL查詢。 –

+2

一個不錯的小技巧就是使用設計器在GUI中定義您的描述,保存它,然後使用上下文菜單獲取創建腳本。這樣你就可以自動生成整個描述代碼。 –

6

這取決於你的意思是「評論」。如果你想描述性文本添加到一列,可以設置Column Description使用SQL Server Management Studio中:

以編程方式設置的描述,您可以用sp_addextendedpropertysp_updateextendedpropertysp_dropextendedproperty存儲過程。例如:

EXEC sp_addextendedproperty 
    @name = N'MS_Description', @value = 'This is the description of my column', 
    @level0type = N'Schema', @level0name = 'dbo', 
    @level1type = N'Table', @level1name = 'MyTable', 
    @level2type = N'Column', @level2name = 'MyColumn' 

我承認語法是有點不方便 - 以下博客帖子包含的存儲過程,使這個過程更容易一點:

+2

這是 「擴展屬性」 使用SQL http://msdn.microsoft.com/en-us/library/ms190243.aspx – gbn

+0

+ 1我完全誤解了這個問題。 –

+1

而不是使用用戶界面,我會知道SQL查詢。 –

相關問題