参考 procedure TAdoBatch.CreateTbable; var i,size:integer; field,fieldss,Ftype:string; begin FSourceTableList.Clear; for i:=0 to Fsourcequery.FieldCount-1 do begin size:=Fsourcequery.Fields[i].Size; case Fsourcequery.Fields[i].DataType of ftInteger: Ftype:='INT'; ftString: Ftype:='CHAR('+inttostr(size)+')'; ftFloat: Ftype:='FLOAT'; ftDate,ftDateTime: Ftype:='DATETIME'; ftCurrency: Ftype:='Currency'; ftSmallint: Ftype:='smallint'; ftBCD: Ftype:='NUMERIC(19,6)'; else ftype:='CHAR('+inttostr(size)+')'; end; //case field:=Fsourcequery.Fields[i].FieldName+' '+Ftype; if uppercase(Fsourcequery.Fields[i].FieldName)<>'A0188' then FSourceTableList.Add(Fsourcequery.Fields[i].FieldName+' ['+Ftype+']'); if fieldss='' then fieldss:=field else fieldss:=fieldss+','+field; end; //for //?aê??¨á¢IN_TEMP#±í with Fdestquery do begin Close; SQL.clear; SQL.Add('if exists(select*from sysobjects where name='+QuotedStr(FDestTablename)+')'); SQL.Add('begin drop table '+FDestTablename +' end '); SQL.Add('create table '+FDestTablename+' ('+fieldss+')'); ExecSQL; end; //with end;
procedure TAdoBatch.CreateTbable;
var
i,size:integer;
field,fieldss,Ftype:string;
begin
FSourceTableList.Clear;
for i:=0 to Fsourcequery.FieldCount-1 do
begin
size:=Fsourcequery.Fields[i].Size;
case Fsourcequery.Fields[i].DataType of
ftInteger: Ftype:='INT';
ftString: Ftype:='CHAR('+inttostr(size)+')';
ftFloat: Ftype:='FLOAT';
ftDate,ftDateTime: Ftype:='DATETIME';
ftCurrency: Ftype:='Currency';
ftSmallint: Ftype:='smallint';
ftBCD: Ftype:='NUMERIC(19,6)';
else
ftype:='CHAR('+inttostr(size)+')';
end; //case
field:=Fsourcequery.Fields[i].FieldName+' '+Ftype;
if uppercase(Fsourcequery.Fields[i].FieldName)<>'A0188' then
FSourceTableList.Add(Fsourcequery.Fields[i].FieldName+' ['+Ftype+']'); if fieldss='' then fieldss:=field
else fieldss:=fieldss+','+field;
end; //for
//?aê??¨á¢IN_TEMP#±í
with Fdestquery do
begin
Close;
SQL.clear;
SQL.Add('if exists(select*from sysobjects where name='+QuotedStr(FDestTablename)+')');
SQL.Add('begin drop table '+FDestTablename +' end ');
SQL.Add('create table '+FDestTablename+' ('+fieldss+')');
ExecSQL;
end; //with
end;
或直接用insert .... select .....