-4
ALTER TABLE Garantor改变列[出生日期]诠释不允许从数据类型datetime到int的隐式转换。使用CONVERT函数来运行此查询
ALTER TABLE Garantor改变列[出生日期]诠释不允许从数据类型datetime到int的隐式转换。使用CONVERT函数来运行此查询
尝试是这样的(你需要创建一个新列,具有转换更新,删除旧的一个然后用旧名称重命名新的)
ALTER TABLE dbo.Garantor
ADD newBirthDate int NOT NULL DEFAULT 0 -- NULL and DEFAULT as required
GO
UPDATE dbo.Garantor
SET newBirthDate = CAST([Birth Date] AS int) -- or CONVERT function, it will do the same
GO
ALTER TABLE dbo.Garantor
DROP COLUMN [Birth Date]
GO
SP_RENAME 'dbo.Garantor.newBirthDate', 'dbo.Garantor.[Birth Date]'
GO
如果列都是空值,可以将其更改为varchar,然后将其更改为int。那可行。 –