sql-server-2008r2-express

Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query


alter table Garantor alter column [Birth Date] int


Solution

  • Try something like this (you'll need to create a new column, update it with a conversion, drop the old one then rename the new one with old one's name)

    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