declare
...
...
Select ...
end这种SQL,如何在TADOQuery上得到结果集?

解决方案 »

  1.   

    跟操作普通的SQL一样,必要的时候增加换行符,比如两次执行select
      

  2.   

    ac1:TAdoConnection;
    aq1:TAdoQuery;begin
      aq1.Close;
      aq1.Connection:=ac1;
      aq1.Sql.Clear;
      aq1.Sql.Add('select * from 表名');
      aq1.Open;
      aq1.First;
      while Not aq1.Eof do
      begin
        列值=aq1.FieldByName('列名').AsString;
        aq1.Next;
      end;end;
      

  3.   

    declare 
    ... 
    ... 
    Select ... 
    endN个步骤可以写在同一句里面,之间加;就可以了
    比如说:
    declare @i int; select @i=field1 from table1 where id=1; select @i i;
      

  4.   

    正确答案是:NextRecordSet方法。