文字不好说 直接举例吧:已有数据:
 ID  Name   BarCode  
 1     按时   111111   ID不是自增的 ID     Name       BarCode     
 2     按时111112     111112    
 3     按时111113     111113   
 .....  求代码  求思路sql

解决方案 »

  1.   

    update tb set name=name+barcode
      

  2.   

    我本来是这样想的while @i<10
    begin
     insert into tb(ID,Name,BarCode) select ID+1,Name+BarCode,BarCode+1 from tb
     set @i=@i+1
    end 不过行不通呀
      

  3.   

    你这个while循环是干嘛的?又没有where语句,单纯在重复10次而已
      

  4.   

    你要这样重复10次的话有个函数可以用:REPLICATE ,具体使用去看联机丛书
      

  5.   

    不是单纯的重复    我表达能力很差呀     不过我鼓捣出来了....declare @i int
    set @i=1
    while @i<10
    begin
     insert into tb(ID,Name,BarCode) select top 1 ID+1,substring(Name,0,2)+cast(BarCode+1 as nvarchar),BarCode+1 from tb order by ID desc
     set @i=@i+1
    end结果还是挺满意的   谢谢两位大神了哈