views:

217

answers:

1

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 doing 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?

+1  A: 

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.

bobince