Sql Substring Function Stackoverflow