CONVERT issue in sqlserver with Msg 529 error

谁都会走 提交于 2019-12-08 17:02:29

You can't convert from text to datetime

You must apply two convert operations.

The first: From text to varchar

The second: From varchar to datetime

So your query will become:

SELECT CONVERT(datetime,
       CONVERT(varchar(30),value), 103)
FROM results

Plus: text datatype is deprecated for new versions of Sql Server, so I strongly advice you to change (if you can) your datatype text into varchar(max).

The DDL code to apply your change is:

ALTER TABLE results ALTER COLUMN value varchar(max)
apomene

You need first to convert text to nvarchar. Try:

select convert(datetime, convert(varchar(30),value), 103) from results

Remarks: See How to convert text column to datetime in SQL

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!