呵呵:)1.
连员工编号(Y_ID)都有重复的,说明这个假帐做得也太失败了,汗2.
楼主说重复的Y_ID不能重复写入工资数据,
而表Table2中竟然有重复的,都被整晕了

解决方案 »

  1.   

    truncate table table2insert table2(y_id,Y_SALARY)
    select y_id,null
    from (select y_no,min(y_id) as y_id from table1 group by y_no) as twhile exists (select 1 from table2 where Y_SALARY is null)
    begin
      set rowcount 1
      update table2 set Y_SALARY=cast(1000+rand()*1000 as int)
      where Y_SALARY is null
      set rowcount 0
    end--检查结果
    select * from table2