在SQL Server A表中有两个字段   PointName(字符型),PointValue(符点型) 共1000条
我想把这一千条中得100 条数据到入到另一表中  需要将这100条一条条得根据PointName 的值查出来
然后写到 B表中  应当怎样写效率会高一些?
   如果要写一条的话
  Dim connA as New ADODB.Connection
  Dim recA As New ADODB.Recordset
    
  Dim connB As New ADODB.Connection
  Dim recB As New ADODB.Recordset
  
sub  openDatebase()
{   
connA.Open "Driver={SQL Server};Server=;Database=;Uid=;Pwd=;"
recA.Open "Select PointName,PointValue from A  where PointName= '某测点'", conna, adOpenStatic,adLockOptimisticconnB.Open "Driver={SQL Server};Server=;Database=;Uid=;Pwd=;"
recB.Open "Select PointName,PointValue from B ", connB, OpenStatic,adLockOptimistic       recB!PointName=recA!PointName
recB!PointValue=recA!PointValue
recB.Update

这样做可以把A表中的一条数据传送给B表  但如果要是传送100条,是不是要用Recordset得open 方法把  A表的纪录集打开关闭100次,这样是不是效率太低了?
如有别的办法,请指点!
 

解决方案 »

  1.   

    dim strsql as string
    strsql=" insert into b(pointname,pointvalue) Select PointName,PointValue from A  where PointName='某测点'" 
    conna.execute strsql
      

  2.   

    Leftie(左手,为人民币服务)  非常感谢你的帮助,你的帮助给了我一个很好的思路
    我已经完成了任务  但是 表A  和表b 是两个不同的库   用 你说的 conna.execute strsql 程序
    会说 找不到表b。 如果表A和表B 在一个库中你的说法完全正确
    敬请在指教
      

  3.   

    修改一下
    dim strsql as string
    strsql=" insert into B库.dbo.b(pointname,pointvalue) Select PointName,PointValue from A库.dbo.A  where PointName='某测点'" 
    conna.execute strsql