sql - Update Query (String --> Date) -


i'm trying update field (type of date) string field.

the string field example : 20/10/2015

i new in sql. tried query:

update [dbo].[employeewithcompcar] set [emer_attachenddate] = cast([emer_info1] date) 

i message:

conversion failed when converting date and/or time character string. 

can me fix it?

thank's!

you need use convert() format. try this:

update [dbo].[employeewithcompcar]     set [emer_attachenddate] = convert(date, [emer_info1], 103); 

the formats available in documentation.

note: in sql server 2012+, use try_convert() instead of convert(). way, if string in wrong format, result null instead of error.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -