Answer: PARSE(), TRY_PARSE() functions are introduced in the SQL Server 2012..
Difference: While attempting to PARSE any column, if you get one or more incorrect values, PARSE function will throw an error. However, if you use TRY_PARSE function, it will not throw error but will return the result as NULL
Ex:
1) SELECT PARSE('249.000' AS INT) AS ParseAsInt
This will return result as 249
2) SELECT PARSE('A249.000' AS INT) AS ParseAsInt throws ERROR because of invalid data
SELECT TRY_PARSE('A249.000' AS INT) AS ParseAsInt returns NULL
Asked In: Many Interviews |
Alert Moderator