Reputation: 12709
I have a Nvarchar
column in a database table which contains date values. Date values are stored in two formats
2008-05-20
22/04/2011
Now I need to convert this column to a date
column. When I'm try the following query:
set dateformat dmy
alter table tblDocumentRevision
alter column RevisionDate date
it returns an error:
Msg 241, Level 16, State 1, Line 2
Conversion failed when converting date and/or time from character string.
The statement has been terminated.
Please help me to solve this
Upvotes: 0
Views: 737
Reputation: 46977
Update the date string in the table so they all have the same format (one that SQL server can cast from) before you change the type to DateTime.
Upvotes: 2