Characters you should never ever use in an object or schema name!

Leave a comment

March 5, 2014 by Kenneth Fisher

You can put pretty much any character you want into an object or schema name by enclosing the name in []’s. This does not however mean that you should. There are two specific cases that I’ve seen that are in general a bad idea.

I’ve seen names that actually have []s around them.

CREATE SCHEMA [[bracket]]]
	CREATE TABLE [[bracket]]] (id int)
SELECT * FROM [[backet]]].[[bracket]]]

And other’s that have periods.

	CREATE TABLE [do.t].[do.t] (id int)
SELECT * FROM [do.t].[do.t]

Why is this a problem? Well you can see from above you have to do extra work to even do a select. Also there are a number of commands that just won’t work. Sp_help for example.

EXEC sp_help [[bracket]].[bracket]]]
EXEC sp_help []

And if nothing else they are really really confusing! So please do not put periods or brackets in object or schema names. Do it for me if not for yourself. I mean there is always that outside chance that I’ll have to work on your systems one day!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 3,755 other subscribers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: