how to the data type of columns #temporary tables and other info on #temp tables?

  • Hi,

    How to the data type of columns in #temporary tables and other info on #temp tables?

    Thanks!

  • You can get that from the system views and DMVs in tempdb.

    For example, select from tempdb.sys.columns to get column and datatype data about temp tables.

    select *

    from tempdb.sys.columns

    where object_id = object_id(N'tempdb..#MyTempTable');

    That'll give you column data about a temp table named #MyTempTable.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • If you have a session that created a Temp Table, just do the following without closing the session and without changing sessions (windows in SSMS)...

    EXEC TempDB..sp_help #nameoftemptable

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

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