curly-brace hell in sql-server

2007-07-23 @ 01:30#

i discovered a *nasty* problem in my sprocs this evening - curly-brace handling!

i forgot that curly braces { and } are special characters in sql server [yipes!]. for some reason, saving a new post using my exyus framework worked fine, but updating that post kept causing sql server to return an error (something value about the input string in the wrong format, etc.). baffled, i rigged up a step in the runtime code to transpose those chars into their ascii equivalents ({ and } respectively). but that was really not the correct answer.

the solution worked, but it gnawed at me. i *knew* there was something i was missing. finally, i started googling and found a reference in msft's online docs to the use of curly braces (in XQuery, btw)

...If you want to use the curly braces as part of your text instead of context-switching tokens, you can escape them as "}}" or "{{"...

once i had the problem identified, i was able to come up with the proper solution. in my case, i updated my post.xsl and put.xsl transforms to properly escape braces within the content.

UPDATE (2007-02-23)
turns out it's only a problem on updates, not new posts. something about how my t-sql code is arranged (i do some comparisons of field contents on updates). so my 'fix' is only needed for PUT and not POST. still, pretty odd stuff.