SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

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

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 [do.t.do.t]

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!

Filed under: Microsoft SQL Server, SQLServerPedia Syndication, T-SQL Tagged: code language, language sql, microsoft sql server, sql statements, T-SQL


My name is Kenneth Fisher and I am Senior DBA for a large (multi-national) insurance company. I have been working with databases for over 20 years starting with Clarion and Foxpro. I’ve been working with SQL Server for 12 years but have only really started “studying” the subject for the last 3. I don’t have any real "specialities" but I enjoy trouble shooting and teaching. Thus far I’ve earned by MCITP Database Administrator 2008, MCTS Database Administrator 2005, and MCTS Database Developer 2008. I’m currently studying for my MCITP Database Developer 2008 and should start in on the 2012 exams next year. My blog is at www.sqlstudies.com.


Leave a comment on the original post [sqlstudies.com, opens in a new window]

Loading comments...