誰能幫幫我,弄了半天也沒法解決,在線等待....


1、alter table pexamdetail add col char(20) default ''

2、alter table pexamdetail drop col
我用第1時可以建立,但用2時就出錯了,信息如下:
Server: Msg 3728, Level 16, State 1, Line 1
'col' is not a constraint.
Server: Msg 3727, Level 16, State 1, Line 1
Could not drop constraint. See previous errors.
不知是怎麼回事,那位能幫忙解答,謝了
[368 byte] By [stevenqi] at [2008-2-13]
# 1
難道沒人知道嗎?555555
stevenqi at 2007-10-20 > top of Msdn China Tech,MS-SQL Server,基础类...
# 2
a.首先你的语句是错误的。
删除列的语句是:
alter table pexamdetail drop column col
b.
直接用上面的语句会出错,提示的错误信息内,有约束名cons_name
(用sp_help 'pexamdetail' 也可得到cons_name)
alter table pexamdetail drop constraint cons_name
删除约束,再执行语句a
j9988-j9988 at 2007-10-20 > top of Msdn China Tech,MS-SQL Server,基础类...
# 3
再问一点相关的问题,就如上面所写,在create table 时,没有为列指定constraint 那么这个约束如何来的?
liu9527-小刀 at 2007-10-20 > top of Msdn China Tech,MS-SQL Server,基础类...
# 4
DEFAULT 本身就是约束,约束名自动生成为“DF__%”
j9988-j9988 at 2007-10-20 > top of Msdn China Tech,MS-SQL Server,基础类...