• masoudk1990 (7/5/2013)


    Ive noticed dudes in this forum uses # for the first letter of their table names.

    Does it have any special meaning?

    Does SQL Server have different behavior with them?

    Or its just a letter like a,b,c... etc?

    #table is a temporary table...it's one that you can create on the fly, and it gets destroyed automatically when your connection is closed.

    SELECT name

    INTO #temp

    from sys.tables

    they are real tables, and are unique to the processes/scope that created them...so a procedure which creates a temp table can be called thousands of times per second, and each instance of the procedure creates it's own temp table, called #temp or whatever, but that do not collide with any other process creating temp tables by the same name.

    technically, a table gets created with a unique name in tempdb, and it might actually be called the same name, but with a unique number appended to the end of it;

    see for yourself:

    select POWER(convert(bigint,2),31) as val into #temp

    select name from tempdb.sys.tables where name LIKE '#temp%'

    --#temp__{snip}__000000000006

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!