June 5, 2011 at 8:20 pm
And we get an error (like below) when we exceed 3 periods.
The object name 'tempdb....#tmptbl' contains more than the maximum number of prefixes. The maximum is 3
What does this periods stands for?
I notice some sql servers reports maximum number of prefixes is 2 (Mine is 3), what is determining the maximum number of prefixes??
Thanks,
cino
June 5, 2011 at 9:07 pm
every object is resolved to a four part name when a statement is compiles
ServerName.DatabaseName.SchemaName.ObjectName
ServerName.DatabaseName.SchemaName.Tablename
sometimes you can skip explicitly nameing the object and leave the word between the periods out, and the compiler will assume a default.
for example:
SELECT * FROM DEV223.SandBox.dbo.ZipCodes
try this to get your mental arms around it:
--create a temp table on the fly:
select 'Hello World' As TheData
INTO #temp
--see the data?
SELECT * FROM #temp --what about with a schema?
SELECT * FROM dbo.#temp --works!
SELECT * FROM tempdb.dbo.#temp --the whole thing with dbname?
SELECT * FROM tempdb.dbo.#temp --the whole thing with dbname?
SELECT * FROM [HOME-PC].tempdb.dbo.#temp --the whole thing with dbname?
SELECT * FROM tempdb..#temp --use the shorthand notation for the "default" schema
SELECT * FROM [HOME-PC].tempdb..#temp --use the shorthand notation for the "default" schema
SELECT * FROM [HOME-PC]...#temp --use the shorthand notation for the "default" schema and default database
SELECT * FROM tempdb..#temp --use the shorthand notation for the "default" schema
Lowell
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply