Kinston beat me to it but, to add a little more checking, here's what I came up with.
--=============================================================================
-- Create and populate a test table. This is NOT a part of the solution.
--=============================================================================
--===== Conditionally drop the test table to make reruns in SSMS easier.
IF OBJECT_ID('tempdb..#TestTable','U') IS NOT NULL
DROP TABLE #TestTable
;
--===== Create and populate the test table on the fly
SELECT DateString
INTO #TestTable
FROM (
SELECT '10.12.2012' UNION ALL --dmy
SELECT '12-10-2012' UNION ALL --mdy
SELECT '2012/10/12' --ydm
)d(DateString)
;
--=============================================================================
-- Demonstrate one possible solution
--=============================================================================
--===== Change all the 3 types of date formats to real dates.
SELECT OriginalDateString = DateString,
ReformattedDate =
CASE
WHEN DateString LIKE '[0-3][0-9].[0-1][0-9].[1-2][0-9][0-9][0-9]' --dd.mm.yyyy
THEN CONVERT(DATETIME,DateString,104)
WHEN DateString LIKE '[0-1][0-9]-[0-3][0-9]-[1-2][0-9][0-9][0-9]' --mm-dd-yyyy
THEN CONVERT(DATETIME,DateString,110)
WHEN DateString LIKE '[1-2][0-9][0-9][0-9]/[0-3][0-9]/[0-1][0-9]' --yyyy/dd/mm
THEN CONVERT(DATETIME,RIGHT(DateString,5)+'/'+LEFT(DateString,4),103)
ELSE NULL
END
FROM #TestTable
;
If that last date format were actually yyyy/mm/dd instead of yyyy/dd/mm, we could make this a whole lot simpler as well as being able to add extra checking.
--Jeff Moden
Change is inevitable... Change for the better is not.