我的库中有十个表,这十个表中有七个表含有hpbh这个列,有没有一个命令能够将所有含有这个列的表中的这个列值改成一个值(如hpdh现在的值是j,h,k等,我想将所有为j的值改成m),有没有一个好的方法,不要用update一个一个表去改,急用呀??如果有写的全一点,是在程序里写,还是在sqlserver里写??一定给分,分不够再加??

解决方案 »

  1.   

    用SQL写吧!不过提取表结构字段,我也不懂!学习!
      

  2.   

    建一个字符串型数组var
      databasename:array[1..7]of string;
      i:integer;procedure ..............
    begin
      databasename[1]:='表一的名字';
      databasename[2]:='表二的名字';
      .
      .
      .  for i:=1 to 7 do 
        with table1 do
        begin
          close;
          tablebame:=databasename[i];
          open;
          edit;
          table1['hpbh']:='m';
          post;
        end;
    end;暂时想到这个方法
      

  3.   

    1、建立个视图,选出七个表的hpdh,然后用Update 修改视图的各个列的值   肯定要用Update的,实际上也相当与执行了7次update;
    2、使用Trigger修改,修改一个表,自动修改其他表,但效率也比较低。
      

  4.   

    如有表t1,...t7 均有hpdh 在sql 的database上
       create view test select t1.hpdh h1,t2.hpdh h2,...t7.hpdh h7 from t1,t2,...t7
          where t1.hpdh=t2.hpdh and t1.hpdh=t3.hpdh and t1.hpdh = t4.hpdh ... and t1.hpdh = t7.hpdh  update test set h1='j',h2='j',...,h7='j' where h1='k'  //把所有k改为j