Monday, March 12, 2012

how to use non-basic ascii chars in stored proc paramter

hi all,

I have a stored procedure with a input parameter ( xml block).

sp: spGetAddr @.xmlText

the style of parameter @.xmlText looks like

<Param RestricBy="UserName IN ('Mayá', 'Bob')"/>

If I use non-basic ASCII character, just like 'á' in the parameter, the execution fails and I get 'The error description is 'An invalid character was found in text content.''

But this kind of special characters should be allowed in the name column of the database table.

If I use the htlm code '&#xE1" to replace 'á' in the parameter, then the execution of the stored procedure is fine. but how can I change all of the possible sepcial characters?

If somebody knows how to handle this issue, please help me. I'm pre-appreciated for all the idea and suggestion!

Thanks,

Jone

When you pass the parameter to the stored procedure, make sure to use an nvarchar string. For example:

N'<Param RestricBy="UserName IN ('Mayá', 'Bob')"/>'

Regards,

Galex Yen

No comments:

Post a Comment