SQL 2000自定义 数据类型

/*          1. 创建用户类型过程(PJ_HV_userdefinetype) */



CREATE procedure PJ_HV_userdefinetype

  @name sysname = null,

  @type sysname = null,

  @rule varchar(8000) = null

as

  declare @stmt varchar(7900)

  declare @tmp sysname

  select @name = lower(rtrim(ltrim(@name))), @type = lower(rtrim(ltrim(@type)))

  execute sp_addtype @name, @type, 'not null'

  if @rule is not null

  begin

    select @tmp = @name + '_rule'

    select @stmt = 'create rule ' + @tmp + ' as ' + @rule

    execute( @stmt )

    execute sp_bindrule @tmp, @name

  end

set nocount on

go



/*          2.创建各种自定义数据类型                                           */

execute PJ_HV_userdefinetype 'normalid', 'int', '@value > 0'   /*主键类型*/

execute PJ_HV_userdefinetype 'description', 'varchar(1000)', 'len(@value) >= 0' /*备注*/

execute PJ_HV_userdefinetype 'valid', 'tinyint', '@value in (0, 1)' /*标志字段*/

你可能感兴趣的:(数据类型)