You might have noticed that T-SQL includes both a CONVERT()
function and a TRY_CONVERT()
function that you can use in SQL Server to perform conversions between data types. But if you’re scratching your head over what the difference is between these two functions, read on!
The difference between CONVERT()
and TRY_CONVERT()
is in the way they handle data types that can’t be converted. One throws an error, while the other returns null. The following examples demonstrate this.