I know similar questions have been asked in the past, but they still haven't given me a proper solution for my case.
I have a database table (third party) that has a varchar
column for a datetime
value.
It contains dates in the following formats.
11181980
8 18 1960
10/01/1960
04-12-1953
041371
7/29/44
Empty String
NULL
When I select this column, I want to bring the date in a standard format (say mm/dd/yyyy
) when available or NULL.
I can only think of a function to do this, but I don't want to do a UDF as I need to make sure it does not error out while trying to convert. There is no try/catch in UDF. I could do a CLR function to make use of more powerful .net features though I would like to avoid it.
Is there any other better way to handle this conversion in SQL Server? Also how should I go about doing this conversion if possible in SQL.
Aucun commentaire:
Enregistrer un commentaire