temp table

  • Ok, here's an unusual one.

    Does anyone know where SQL Server stores or gets the system- generated numeric suffix ?

    e.g.

    create table #x (id int)

    and when you look in sysobjects

    select * from tempdb..sysobjects where type = 'u'

    this is what you get.

    #x______________________________000000102330

    that suffix will remain the same if you keep creating temp tables with the same session. so SQL Server must store or get that from somewhere right.

    So if anyone with a bit more SQL Internals please share some light on this.

    Cheers.

    -¢ödêmån-


    -¢ödêmån-

  • The number is generated from the SPID or GUID used to create the object

  • Anzio can you elaborate a bit more on your post please ... doesnt really give me more to go on with.

    -¢ödêmån-


    -¢ödêmån-

  • SQL Server generates a 128 byte unique name for each temporary table. The last 12 charaters i.e. 000000102330 is the Current Session ID generated by SQL Server. So every temporary table created in this session will always contain these charaters at the end. The session ID is internally generated by SQL Server whenever a session is started.

    HTH

    Regards.

  • Guys,

    I think you're missing it ... you are just repeating what I've already posted up there.

    I know that SQL creates the numeric suffix which is appended at the end of the name of the temp table.

    The question is ... does anyone know where, how it is created, so I can query it back!?

    Cheers,

    -¢ödêmån-


    -¢ödêmån-

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply