在delphi里调用,这么写的 with Query1 do
begin
Active:=False;
Parameters.ParamByName('cYear').Value :=cYear;
Parameters.ParamByName('cMonth').Value:=cMonth;
Active:=True;
end;
begin
Active:=False;
Parameters.ParamByName('cYear').Value :=cYear;
Parameters.ParamByName('cMonth').Value:=cMonth;
Active:=True;
end;
写错了,into tab1 from tab2
with Query1 do
begin
Active:=False;
SQL.Text := 'select into tab1 from tab2 where cYear=:cYear and cMonth=:cMonth group by cName, cSex';
Parameters.ParamByName('cYear').Value :=cYear;
Parameters.ParamByName('cMonth').Value:=cMonth;
Active:=True;
end;
SQL.Text := 'select into tab1 from tab2 where cYear=''' + cYear + ''' and cMonth=''' + cMonth + ''' group by cName, cSex';
直接使用变量就行:set @sql = @sql + ' into tab1 from tab1 where cYear='‘’+cYear+'‘’ and cMonth='‘’+cMonth+‘’' group by cName, cSex'
exec(@sql)