在delphi里调用,这么写的  with Query1 do
    begin
      Active:=False;
      Parameters.ParamByName('cYear').Value :=cYear;
      Parameters.ParamByName('cMonth').Value:=cMonth;
      Active:=True;
    end;

解决方案 »

  1.   

    into tab1 from tab1 where    这是什么语法呀
      

  2.   


    写错了,into tab1 from tab2
      

  3.   

     ' ... where cYear=:cYear and cMonth=:cMonth ...'
      

  4.   


    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;
      

  5.   

    正确解,如果你的不想用参数替换的方式,可以直接使用变量
    SQL.Text := 'select into tab1 from tab2 where cYear=''' + cYear + ''' and cMonth=''' + cMonth + ''' group by  cName, cSex';
      

  6.   


    直接使用变量就行:set @sql = @sql + ' into tab1 from tab1 where cYear='‘’+cYear+'‘’ and cMonth='‘’+cMonth+‘’' group by  cName, cSex'
    exec(@sql)
     
      

  7.   

    动态的SQL就是不行啊,静态的咋写都不出错,最后写到存储过程里传递才不出错了