select  '0'+ltrim(cast(rand()*16 as int)+820)0830
0832
0820
0835
.............

解决方案 »

  1.   

    select coloo1 from 表 where substring(coloo1,12,4) >='0820' and substring(coloo1,12,4) <='0835'
      

  2.   

    create table tb(COL001 varchar(64)) 
    insert tb select '0012008010106003707887204090' 
    union all select '0012008010106481205201966090' 
    union all select '0012008010107464207861626090' 
    union all select '0012008010107474403140821090' 
    union all select '0012008010106003707887204090' 
    union all select '0012008010106481205201966090' 
    union all select '0012008010107464207861626090' 
    union all select '0012008010107474403140821090' 
    union all select '0012008010107474614168049090' 
    select stuff(COL001, 12, 4, right(10000+abs(checksum(newid()))%16+820, 4)) from tb
    /*
    --------------------------------------------------------------------
    0012008010108213707887204090
    0012008010108251205201966090
    0012008010108344207861626090
    0012008010108214403140821090
    0012008010108283707887204090
    0012008010108301205201966090
    0012008010108294207861626090
    0012008010108204403140821090
    0012008010108254614168049090(9 row(s) affected)
    */drop table tb
      

  3.   

    create table tb(COL001 varchar(64)) 
    insert tb select '0012008010106003707887204090' 
    union all select '0012008010106481205201966090' 
    union all select '0012008010107464207861626090' 
    union all select '0012008010107474403140821090' 
    union all select '0012008010106003707887204090' 
    union all select '0012008010106481205201966090' 
    union all select '0012008010107464207861626090' 
    union all select '0012008010107474403140821090' 
    union all select '0012008010107474614168049090' update tb 
    set col001=stuff(COL001, 12, 4, right(10000+abs(checksum(newid()))%16+820, 4))select * from tb
    /*
    COL001
    ----------------------------------------------------------------
    0012008010108203707887204090
    0012008010108311205201966090
    0012008010108244207861626090
    0012008010108214403140821090
    0012008010108203707887204090
    0012008010108351205201966090
    0012008010108344207861626090
    0012008010108354403140821090
    0012008010108264614168049090(9 row(s) affected)
    */drop table tb