Anney




05/08/12       1
   tempdb.dbo.sysobjects
   tempdb.dbo.[#T]




                            05/08/12   2
05/08/12   3
   Truncates the table name to 116 characters,
    including the pound sign (#)
   Pads shorter names to 116 characters, using
    underscores (_)
   Appends a 12-digit numeric suffix




                                      05/08/12    4
   Using tempdb
   Selected temptable name
   Alt+F1 or EXEC sp_help ‘temptable Name’




                                    05/08/12   5
05/08/12   6
05/08/12   7
05/08/12   8
   If you have less than 100 rows generally use
    a table variable.  Otherwise use  a temporary
    table.  This is because SQL Server won't
    create statistics on table variables.
   If you need to create indexes on it then you
    must use a temporary table.
   When using temporary tables always create them
    and create any indexes and then use them.  This
    will help reduce recompilations.  The impact of
    this is reduced starting in SQL Server 2005 but
    it's still a good idea.

                                        05/08/12      9
   http://manuals.sybase.com/onlinebooks/group-a
    BookTextView/19950;pt=20233
   http://www.sqlteam.com/article/temporary-table




                                    05/08/12   10
05/08/12   11

20120504 tsql temp_table

  • 1.
  • 2.
    tempdb.dbo.sysobjects  tempdb.dbo.[#T] 05/08/12 2
  • 3.
  • 4.
    Truncates the table name to 116 characters, including the pound sign (#)  Pads shorter names to 116 characters, using underscores (_)  Appends a 12-digit numeric suffix 05/08/12 4
  • 5.
    Using tempdb  Selected temptable name  Alt+F1 or EXEC sp_help ‘temptable Name’ 05/08/12 5
  • 6.
  • 7.
  • 8.
  • 9.
    If you have less than 100 rows generally use a table variable.  Otherwise use  a temporary table.  This is because SQL Server won't create statistics on table variables.  If you need to create indexes on it then you must use a temporary table.  When using temporary tables always create them and create any indexes and then use them.  This will help reduce recompilations.  The impact of this is reduced starting in SQL Server 2005 but it's still a good idea. 05/08/12 9
  • 10.
    http://manuals.sybase.com/onlinebooks/group-a BookTextView/19950;pt=20233  http://www.sqlteam.com/article/temporary-table 05/08/12 10
  • 11.