Export (0) Print
Expand All

SR0011: Avoid using special characters in object names

RuleId

SR0011

Category

Microsoft.Naming

Breaking Change

Breaking

The name of at least one database object contains at least one special character.

If you name a database object by using any character in the following table, you make it more difficult not only to reference that object but also to read code that contains the name of that object:

Character

Description

Whitespace character

[

Left square bracket

]

Right square bracket

'

Single quotation mark

"

Double quotation mark

To resolve this issue, you must remove all special characters from the object name. If the object is referenced in other locations in your database project (such as in database unit tests), you should use database refactoring to update the references. For more information, see Rename All References to a Database Object.

You might have to suppress these warnings if one or more other applications reference the database object and you cannot change the applications.

In the first example, a table contains a column that has a special character in its name. In the second example, the name does not contain a special character.

CREATE TABLE [dbo].[TableWithProblemColumn]
( 
[ID] INT NOT NULL IDENTITY(0, 1), 
[Small'String] VARCHAR(10)
)
ON [PRIMARY]

CREATE TABLE [dbo].[FixedTable]
( 
[ID] INT NOT NULL IDENTITY(0, 1), 
[SmallString] VARCHAR(10)
)
ON [PRIMARY]

Community Additions

ADD
Show:
© 2014 Microsoft