SQL Server equivalent of Javascript UnEscape
I have a table in SQL Server 2008 with a column having the string stored in JavaScript Escape format. When queried from application, I am doin开发者_如何学编程g the JavaScript UnEscape of the returned string, so no issues.
How do i UnEscape the string when I directly query the database? Is there any equivalent function for JavaScript UnEscape in SQL?
I have a table in SQL Server 2008 with a column having the string stored in JavaScript Escape format.
That's really not a good idea. It's almost always best to store all your text unencoded in the database to make database-level processing possible.
Is there any equivalent function for JavaScript UnEscape in SQL?
No, neither in ANSI SQL nor any variant including T-SQL.
escape/unescape is a non-standard encoding format which is only supported by JavaScript. It is not the same as URL-encoding and has no place on the backend. (If it has any place on the frontend anyway, which since they invented encodeURIComponent it probably doesn't.)
If you are determined to have this in the database layer, you would have to use a stored procedure to fetch and decode the results.
精彩评论