Access2003中的 更改 字段的长度 的语句为:
alter table [dv_user] ALTER COLUMN [xzdata] varchar(255)
当修改字段长度时,如果需要修改的字段为索引时会出现报错的情况:
Server: Msg 5074, Level 16, State 8, Line 1
The index 'araplog3' is dependent on column 'PeonyRef'.
Server: Msg 4922, Level 16, State 1, Line 1
ALTER TABLE ALTER COLUMN PeonyRef failed because one or more objects access this column.
原因:
索引对应的字段长度与表中的对应的字段长度不一致。
解决方法:
先去除包含该字段的索引,如上面提到的"araplog3",然后重建这个索引。
Drop Index ARAPLOG.araplog3
alter table ARAPLOG alter column PeonyRef char(10) null;
CREATE
INDEX [araplog3] ON ARAPLOG ([PeonyRef])
ON [PRIMARY]