Factor out error message formatting in sqlsrv database, closes #1393