USP_SCHEMA_TABLE_SETTABLECOMMENT

Parameters

Parameter Parameter Type Mode Description
@TABLENAME nvarchar(128) IN
@COMMENT nvarchar(4000) IN

Definition

Copy

create procedure BBDW.[USP_SCHEMA_TABLE_SETTABLECOMMENT]
@TABLENAME nvarchar(128),
@COMMENT nvarchar(4000)
as
  declare @VALUE sql_variant

  select @VALUE = value from fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'BBDW', N'table', @TABLENAME, default, default)

if @VALUE is null
  -- property doesn't exist, so add it
  exec sys.sp_addextendedproperty N'MS_Description', @COMMENT, N'SCHEMA', N'BBDW', N'table', @TABLENAME
else
  -- property already exists, so update it
  exec sys.sp_updateextendedproperty N'MS_Description', @COMMENT, N'SCHEMA', N'BBDW', N'table', @TABLENAME