问题描述是这样的:比如DataSet中有二个表,Customer表,order表。
Customer Table:
ID  name sex address 
1   小张 男 北京   
2 小王  男 上海
3 小李  女 天津
共有30条记录order Table: 
ID orderdate   customer
1 2008/02/24  小李
2   2008/02/25  小王
3 2008/02/23   小王
4 2008/03/23   小张
....................
....................
共有三万条记录
现在想快速的将order表中,Customer列更新为Customer表中对应的ID号,请问有没有很好的方法?谢谢! 

解决方案 »

  1.   

    在服务器上可以用sql语句直接查询select a.id,a.orderdte,b.id from order a,Customer b
    where a.customer =b.name
      

  2.   

    现在可能有Customer表中不存在的,则不更新,怎么实现?就是说如果Customer中有,则更新order表,如果没有,则保持原有的信息?
      

  3.   

    你就没有觉得你的设计有问题?
    判断Customer是否存在并返回不同结果
    [code=SQL]if object_id('Customer') is null
    select * from order 
    else
    select a.id,a.orderdte,b.id as customer  from order a,Customer b 
    where a.customer =b.name[/code]
      

  4.   

     if object_id('Customer') is null
    select * from order 
    else
    select a.id,a.orderdte,b.id as customer  from order a,Customer b 
    where a.customer =b.name