Tmp Tables

  • How do I test for tmp tables??? I want to test if the tmp table exists if so drop tmp table.

    Steve Johnson


    Steve Johnson

  • The following will work for you;

    if exists

    (

    select name from tempdb..sysobjects where name like '#YourTable%'

    )

    drop table #YourTable

    Hope this helps.

    David

    David

    @SQLTentmaker

    “He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot

  • Thanks David that will work great!!!

    Steve Johnson


    Steve Johnson

  • There's an easier statement:

    if not OBJECT_ID('#TableName') is Null

    and so on.

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

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