生成卡号,要求卡号各位都不带4

解决方案 »

  1.   

    create table ddh(a varchar(20) check (charindex('4',a)=0))
    insert ddh select 'sdfasdf' 
    insert ddh select 'sdfas4df'
    select * from ddh
      

  2.   

    表中有ID,卡号,两个字段,其中id-->int,卡号为定长的字符型可以取最大ID+1,如果发现含有4,则再加1,用While循环,直到找到不含4的ID为止,然后
    用right('0000000000' + cast(id as varchar(100)),6)获取卡号,这里假定卡号长度6位
      

  3.   

    create  proc  usp_test as
    declare @no int
    select @no=max(卡号)  from  tb
    if right(@no,1)=3  set @no=@no+1
    if right(@no,2)=39 set @no=@no+11
    if right(@no,3)=339 set @no=@no+111
    if right(@no,4)=3339 set @no=@no+1111
    if right(@no,5)=33339 set @no=@no+11111
    if right(@no,6)=333339 set  @no=@no+111111
    go
      

  4.   

    tanxiangfeng(黑鼻子),wangtiecheng(不知不为过,不学就是错!)能把代码写具体点吗
      

  5.   

    declare @i int,@t int
    declare @tb table (a int)
    select @i=1,@t=0
    while @i<24
      begin
         if(charindex('4',cast(@t+1 as varchar))<>0)
            begin
              insert @tb select @t+2
              set @t=@t+2
            end
         else 
            begin
               insert @tb select @t+1
                set @t=@t+1
            end
         set @i=@i+1   
      end
    select * from @tb
      

  6.   

    生成所有的卡号,然后
    delete from card where cardid like '%4%'
    哈哈~
      

  7.   


    declear @kh int,
    @khzs int

    set @kh = 1
    set @khzs = 1000
    do while @kh <= @khzs
    begin
    if CHARINDEX(cast(@kh as char),'4') > 0 
    inset into tab1 value(@kh)
    end
    @kh = @kh+1
    next

    select * from tab1