在delphi中如何动态改变sql server数据库的表结构

解决方案 »

  1.   

    用alter table 命令with query do
    begin
    close;
    sql.clear;
    sql.add('create table a(b int)');//创建表
    execsql;
    close;
    sql.clear;
    sql.add('alter table aadd column c int');//修改表
    execsql;
    end;
      

  2.   

    但在query中列名是不确定的,所以需要参数,
    但在运行时提示错误.
    程序如下:
    query1.close;
    query1.sql.add(alter table test add :col decimal(4,1) null);
    query1.parambyname('col").value:=edit1.text;
    query1.exesql;