Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulate COMMENT ON in SQL Server using sp_updateextendedproperty #6986

Closed
lukaseder opened this issue Jan 4, 2018 · 0 comments
Closed

Emulate COMMENT ON in SQL Server using sp_updateextendedproperty #6986

lukaseder opened this issue Jan 4, 2018 · 0 comments

Comments

@lukaseder
Copy link
Member

lukaseder commented Jan 4, 2018

This is how it can be done:

EXEC sp_updateextendedproperty  --or sp_addextendedproperty 
@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;

Or, more specifically (as we need to distinguish between "add" and "update"):

BEGIN TRY
  EXEC sp_addextendedproperty 'MS_Description', 'Table X', 'schema', 'dbo', 'table', 't';
END TRY
BEGIN CATCH
  EXEC sp_updateextendedproperty 'MS_Description', 'Table X', 'schema', 'dbo', 'table', 't';
END CATCH

Also, if a table is not qualified, then we can replace the 'schema', 'dbo' arguments by 'schema', 'schema_name()'


See:

@lukaseder lukaseder added this to the Version 3.11.0 milestone Jan 4, 2018
@lukaseder lukaseder changed the title Emulate COMMENT ON in SQL Server using Emulate COMMENT ON in SQL Server using sp_updateextendedproperty Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant