Hi Ash1807,
For SQL Server 2012 or onwards, TRY_PARSE is suggested in your scenario.
- Returns the result of an expression, translated to the requested data type, or null if the cast fails in SQL Server. Use TRY_PARSE only for converting from string to date/time and number types.
SELECT TRY_PARSE('Jabberwokkie' AS datetime2 USING 'en-US') AS Result;
Result
---------------
NULL
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support
No comments:
Post a Comment