SqlServer无法将列 ‘Column1’ 的数据类型更改为 timestamp

数据库 码拜 5年前 (2019-03-30) 4815次浏览 0个评论

SqlServer 执行Sql 修改表 ALTER TABLE [dbo].[t1] ALTER COLUMN [c1] timestamp NOT NULL

报错:无法将列 ‘Column1’ 的数据类型更改为 timestamp

修改表列SQL模板格式(部分)

ALTER TABLE [ database_name . [schema_name ] . | schema_name. ] source_table_name {

ALTER COLUMN column_name { type_name [ ( precision [ , scale ] ) ] [ COLLATE Windows_collation_name ] [ NULL | NOT NULL ] }

}

微软官方解释:

type_schema_name. ] type_name The new data type for the altered column, or the data type for the added column. You can’t specify type_name for existing columns of partitioned tables. type_name can be any one of the following types:

  • A SQL Server system data type.
  • An alias data type based on a SQL Server system data type. You create alias data types with the CREATE TYPE statement before they can be used in a table definition.
  • A .NET Framework user-defined type, and the schema to which it belongs. You create user-defined types with the CREATE TYPE statement before they can be used in a table definition.

The following are criteria for type_name of an altered column:

  • The previous data type must be implicitly convertible to the new data type.
  • type_name can’t be timestamp.
  • ANSI_NULL defaults are always on for ALTER COLUMN; if not specified, the column is nullable.
  • ANSI_PADDING padding is always ON for ALTER COLUMN.
  • If the modified column is an identity column, new_data_type must be a data type that supports the identity property.
  • The current setting for SET ARITHABORT is ignored. ALTER TABLE operates as if ARITHABORT is set to ON.

可以改用其他方式处理:删掉列,添加新列


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明SqlServer无法将列 ‘Column1’ 的数据类型更改为 timestamp
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!