How to Convert SQL Error into Text

In this post, I explained SQL logic to convert SQL error into a text message using DSNTIAR.