The solution works well here. The main statement contains a built-in try-parse method:
SELECT TRY_PARSE('02/04/2016 10:52:00' AS datetime USING 'en-US') AS Result;
Here we implemented in the production version:
UPDATE dbo.StagingInputReview SET ReviewedOn = ISNULL(TRY_PARSE(RTrim(LTrim(ReviewedOnText)) AS datetime USING 'en-US'), getdate()), ModifiedOn = (getdate()), ModifiedBy = (suser_sname()) -- Check for empty/null/'NULL' text WHERE not ReviewedOnText is null AND RTrim(LTrim(ReviewedOnText))<>'' AND Replace(RTrim(LTrim(ReviewedOnText)),'''','') <> 'NULL';
The ModifiedOn and ModifiedBy columns are for internal database tracking only.
See also these Microsoft MSDN links:
MAbraham1 Feb 10 '16 at 15:18 2016-02-10 15:18
source share