Insert special characters into SQL Server 2008 database

你。 提交于 2019-12-12 02:17:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!