drop and create temptable

  • Hi

    i want to drop a temptable

    and then create it again

  • Ok.

    DROP TABLE #TableName

    CREATE TABLE #TableName (<table definition>)

    Is there a question here?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL

    DROP TABLE #TempTable

    CREATE TABLE #TempTable

    (

    A INTEGER,

    B VARCHAR(10) ,

    C MONEY,

    D XML

    )

    You can run this code many times, without the error "Object already existing"

    Hope this is what u wanted..

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

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