问题
The ' ' character cannot be included in a name.
I use a log manager to log the error to SQL Server 2008 database. Of course, it will raise another error in the SQL Server because it contains special characters' '
. So what is the best way to handle special characters in SQL Server.
回答1:
This is because you are using a space in an XML name. Correct your XML code to not have spaces in any tag names, this isn't SQL Server 2008 specific.
回答2:
To get a column to handle special characters define it as a NVARCHAR instead of a VARCHAR.
回答3:
Your question is a bit vague. Do you want to prevent the user from having a space? And if so, do you want to not allow there to be a space character, or just get the space character out? If so, do something like replace(@yourInputString, ' ', '')
.
If this is not what you are looking for, please clarify your question and your exact requirements.
来源:https://stackoverflow.com/questions/8228833/insert-special-characters-into-sql-server-2008-database