在sqlserver2000中自动生成8位编号应该怎么做啊?是写一个过程吗?

解决方案 »

  1.   

    create Function T_Test()
    returns varchar(8)
    as
    begin
       declare @ID varchar(8)
       select right(cast(100000001+isnull(max(filed1),0) as  varchar),8) from Tb
       return @ID
    end
      

  2.   

    declare @t table(id varchar(8))
    insert into @t select 'A'+right(10000001+isnull(right(max(id),7),0),7) from @t
    insert into @t select 'A'+right(10000001+isnull(right(max(id),7),0),7) from @t
    insert into @t select 'A'+right(10000001+isnull(right(max(id),7),0),7) from @t
    insert into @t select 'A'+right(10000001+isnull(right(max(id),7),0),7) from @t
    insert into @t select 'A'+right(10000001+isnull(right(max(id),7),0),7) from @tselect * from @t--可以写成一个函数,作为改列的默认值
      

  3.   

    函数中含有的 SELECT 语句无法向客户端返回数据。