Reputation: 461
I have problem to alter the database field from datetime
to integer
with values using SQL Server 2005
My code is...
alter table overtime alter column adate numeric(5)
while using this query am getting error like this
Disallowed implicit conversion from data type datetime to data type numeric, table ‘DaiichiPayroll.dbo.Overtime’, column ‘adate’. Use the CONVERT function to run this query.
Any solutions?
Upvotes: 1
Views: 764
Reputation: 453318
Whilst Sachin's answer is probably the best solution you should be aware that the table will still continue to use the storage space for the deleted column until you rebuild the clustered index.
For that reason it would be quite nice if there was some explicit convert
syntax that could be run to, for example, change an 8 byte datetime
column to an 8 byte bigint
column but AFAIK none exists.
An alternative would be to use SSMS to generate the script for you. This will generate a script that rebuilds the whole table. If you have a large table or many NCIs the blocking overhead of this may well be unacceptable however.
Upvotes: 2
Reputation: 55489
The server is unable to convert your dateTime column to numeric implicitly. One of the solution is to -
Upvotes: 6