参数除了在where子句中有效外,其他地方均是无效的。
应该这样:
adoquery1.sql.add(Format('create table %s (name char(4))', ['y']));
adoquery1.execusql; 

解决方案 »

  1.   

    adoquery1.sql.append('create table '+y+' (name char(4))');
      

  2.   

    这种创建表的方式在SQL Server中也不可能这样创建
    如果是表明采用变量的情况下:
    假如在SQL Server中
    Declare @TableName
    Exec('Create table ' + @TableName + '(name char(4))')
    ^^^^^自己查找他的帮助去,在Delphi中:
    var
      X: String;
    Adoquery1.sql.append('Create table ' + X + ' (name char4))');
    再试试看
    Good LuckePing :o)
      

  3.   

    y :='abc';
    ...
    adoquery1.sql.Add('select * from student where name = ''' + y +''' '); 
    adoquery1.execusql;