武汉会展中心近期展览:slqserver中给表增加一个字段的语句怎么写

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/05 23:52:20
我的语句是:alter table test add isactive smallint(6) not null default 0;
返回的错误是:
com.microsoft.jdbc.sqlserver.SQLServerConnection@12b6651
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]? 7 ?????: ??????? int ??????
加了 WITH VALUES后仍然返回错误!!
我的程序如下
String sql_s1 = "alter table test add isactive smallint(6) not null default 0 WITH VALUES;";
int iBack=stmt_s.executeUpdate(sql_s1);
System.out.println("isactive:"+iBack);

com.microsoft.jdbc.sqlserver.SQLServerConnection@12b6651
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]? 7 ?????: ??????? smallint ??????

不能给smallint类型指定长度,改成下面这样就行了,在查询分析器里测试通过。
alter table table3
add isactive smallint not null
default 0 WITH VALUES

alter table test
add isactive smallint(6) not null
default 0 WITH VALUES

语句好像不能直接用SQL语句实现,我只是在查询分析器里边测试的