I want a check constraint. That checks the date column, whether date is in yyyy-MM-dd format or not.
I have no idea. But I simply tried,
create table #date( dob date check (dob like 'yyyy-MM-dd'))
insert #date values( '2018-09-24')
So date conversion error is remains.
Update 1
Note:
@@version: Microsoft SQL Server 2012- If
datecolumn is invarchar, then it is also welcome. - Some answers are containing the
convert(). But my scenario was, front end teams are inserting the values asdd-MM-yyyy. I told many time that insert correct format asyyyy-MM-dd(as per our procedure). But they cant. so I want to restrict their inserting values according to format.
Thanks in advance.
TamilPugal.
Try this to get the expected output.