0

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.

Rauf
  • 12,326
  • 20
  • 77
  • 126

3 Answers3

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.

Nick Garvey
  • 2,980
  • 24
  • 31
  • Please see the text 'So what is the best way to handle special characters in SQL Server'. I know the `' '` is there. I want to know the best way to handle this type of special characters in SQL Server. Ohkie ? :) – Rauf Nov 22 '11 at 15:03
  • 1
    I am letting you know that you are not understanding what the error is correctly. This error should be corrected in a location not related to the SQL Server. – Nick Garvey Nov 22 '11 at 15:04
  • @Rauf: Nick is 100% correct. XML does not allow spaces in element names. It is *not* a SQL Server problem. Remove spaces before sending to SQL Server – gbn Nov 22 '11 at 17:21
1

To get a column to handle special characters define it as a NVARCHAR instead of a VARCHAR.

Lost in Alabama
  • 1,653
  • 10
  • 16
0

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.