字段类型是什么? 如
 
  alter table 表名 alter column 字段名 varchar(30)

解决方案 »

  1.   

    alter table tb alter column name varchar(10) not null
    因為是主鍵﹐所以加not nullcreate table tb(name varchar(5) primary key not null,num numeric(10))
    insert into tb(name,num)
    select 'aa',10
    union all select 'bbb',nullselect * from tbinsert into tb(name,num)
    select 'aabb',10
    union all select 'bbbcccc',null錯誤 ﹕
    Server: Msg 8152, Level 16, State 9, Line 1
    String or binary data would be truncated.
    The statement has been terminated.
    修改之后alter table tb alter column name varchar(10) not nullinsert into tb(name,num)
    select 'aabb',10
    union all select 'bbbcccc',null--刪除
    drop table tb
      

  2.   

    ALTER TABLE MyTable ALTER COLUMN NullCOl NVARCHAR(20) NOT NULL
      

  3.   

    表 aaa 主键 asdf 用语句
    ALTER TABLE aaa ALTER COLUMN asdf varchar(20) not null
    出现提示:
    服务器: 消息 5074,级别 16,状态 8,行 1
    对象 'PK_aaa' 依赖于 列 'asdf'。
    服务器: 消息 4922,级别 16,状态 1,行 1
    ALTER TABLE ALTER COLUMN asdf 失败,因为有一个或多个对象访问此列。
    请恢复的各位解释一下