Specifying schema for temporary tables

Posted by Tom Hunter on Stack Overflow See other posts from Stack Overflow or by Tom Hunter
Published on 2011-11-29T13:59:02Z Indexed on 2011/11/29 17:50 UTC
Read the original article Hit count: 282

Filed under:
|
|
|

I'm used to seeing temporary tables created with just the hash/number symbol, like this:

CREATE TABLE #Test
(
    [Id] INT
)

However, I've recently come across stored procedure code that specifies the schema name when creating temporary tables, for example:

CREATE TABLE [dbo].[#Test]
(
    [Id] INT
)

Is there any reason why you would want to do this? If you're only specifying the user's default schema, does it make any difference? Does this refer to the [dbo] schema in the local database or the tempdb database?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server