SQL:在此上下文中不允许使用false

Rah*_*ain 4 sql sql-server-2008

在执行以下SQL查询时

alter table tablename add columnname boolean not null default false;
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息:

The name "false" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

我该怎么解决这个问题?建议?

Rob*_*obB 6

列类型应该是bit字段.

在SQL中,您使用01设置bit字段.这些值在SQL Server Management Studio中显示为falsetrue对应于01.

alter table tablename add columnname bit not null default 0;
Run Code Online (Sandbox Code Playgroud)