怎样批量更新数据,update

解决方案 »

  1.   

    update tablename set a=1,b=2 where ...
      

  2.   

    update tableName
    set col='some value'
    where....
      

  3.   


    UPDATE SC
        SET SC.S#='S005'
        WHERE S#='S001'
    ----------
    把表字段为S#的'S001'全部修改成'S005' 这样算批量处理吗
      

  4.   

    是后面跟select查出来的比如:update news_newstab 
    set n_modifyDate = (select n_createdate from news_newstab t0 where  n_id = t0.n_id)
    where n_modifyDate  is null
      

  5.   

    update news_newstab
    set n_modifyDate = n_createdate
    where n_modifyDate  is null 
      

  6.   


    create table test(time datetime)
    insert test select '2009-1-2'
    union all select '2003-11-2'
    union all select '2004-3-21'
    union all select '2005-3-22'
    union all select '2006-5-2'
    go
    select * from test
    time                                                   
    ------------------------------------------------------ 
    2009-01-02 00:00:00.000
    2003-11-02 00:00:00.000
    2004-03-21 00:00:00.000
    2005-03-22 00:00:00.000
    2006-05-02 00:00:00.000
    update test set time=(select getdate()) where time='2006-5-2';
    select * from test(所影响的行数为 1 行)time                                                   
    ------------------------------------------------------ 
    2009-01-02 00:00:00.000
    2003-11-02 00:00:00.000
    2004-03-21 00:00:00.000
    2005-03-22 00:00:00.000
    2009-02-05 14:08:08.840(所影响的行数为 5 行)
    (所影响的行数为 5 行)
      

  7.   

    lz的表述不清楚哎
    究竟是批量更新  某些字段得值成相同得值
    还是  批量更新  某些字段得值成不同得值第一种  就用UPDATE来完成第二种得话似乎不能用一条语句实现
      

  8.   

    update news_newstab 
    set n_modifyDate = t0.n_createdate from news_newstab,t0 where  news_newstab.n_id = t0.n_id and news_newstab.n_modifyDate  is null