ID号什么规则?
UPDATE T1
SET ID='1' WHERE NAME=?

解决方案 »

  1.   

    名称NAME有重复吗?没有的话,就用上面的语句
      

  2.   

    也可以自动生成
    ALTER TABLE T1 ADD IDX INT INDENTITY(1010001,1)
    GO
    UPDATE T1
    SET ID=CONVERT(CHAR(10),IDX)
    GO
    ALTER TABLE T1 DROP COLUMN IDX
    GO
      

  3.   

    select name,IDENTITY(int,1,1) as Id into #Temp from 商品表update 商品表
    set id='101'+case when t.id<10 then '000'+cast(t.id as char(1))
       when t.id>=10 and t.id<100 then '00'+cast(t.id as char(2))
       when t.id>=100 and t.id<1000 then '0'+cast(t.id as char(3))
       when t.id>=1000 and t.id<10000 then cast(t.id as char(4))
       end
    from 商品表 a,#Temp t
    where a.name=t.name
      

  4.   

    --無規則生成IDUPDATE YourTableName
    SET ID=LEFT(NEWID(),10)
    WHERE ID IS NULL
      

  5.   

    YES,不过飘香的ID是带字母的,我的是从1010001开始递增加一的数字