本帖最后由 tomelrg 于 2010-09-20 14:24:39 编辑

解决方案 »

  1.   

    --1
    update t2 set file1=t1.id
    from t1,t2 where t2.file2=t1.file2
      

  2.   

    问题一:update t2
    set file1 = t1.id
    from t2 , t1
    where t2.file2 = t1.file2
      

  3.   

    1.UPDATE a SET file1=b.file1
    FROM t2 a INNER JOIN t1 b
    ON a.file2=b.file22.2000可以用变量更新 
    2008可以rownumber
      

  4.   


    update t2 set file1=t1.id
    from t1,t2
    where t2.file2=t1.file2
      

  5.   

    从别的表中选取数据的时候下功夫
    2005 row_nubmer
    2000可以根据ID列或者主键,唯一列等子查询处理
      

  6.   

    ;with aa as (
    select 字段1,字段3,row_number() over (partition by 字段1 order by select 1 )as 字段2
    from tb
    )
    select 字段1 字段2  字段3
    from aa
      

  7.   


    ;with aa as (
    select 字段1,字段3,row_number() over (partition by 字段1 order by select 1 )as 字段2
    from tb
    )
    select 字段1 字段2 字段3
    from aa
      

  8.   

    UPDATE a SET file1=b.file1
    FROM t2 a INNER JOIN t1 b
    ON a.file2=b.file2
      

  9.   


    -1
    update t2
    set file1 = t1.id
    from t2 inner join  t1
    on t2.file2 = t1.file2
    -2 使用row_number,rank通过partition by分区 排序可解决 但是在2005版本中
     
    select col1,col2,col3 from 
         (select col1,rank() over(partition by col1 order by col1 asc) as col2,col3 form tb) as a