Object_ID Drop Check not working

  • Hi,

    I have the following check at the beginning of a query, but it is failing to drop the temp table if it already exists.

    if object_id('#temp_StartingValuesBaseData','u') is not null

    drop table #temp_StartingValuesBaseData

    This is followed by a select * into #temp_StartingValuesBaseData from (another select statement)

    Can anyone advise why this may be happening. I appreciate you may need more info. Please let me know what.

    Many thanks,

    Jason

  • Hi,

    Could you try:

    if object_id('tempdb..#temp_StartingValuesBaseData') is not null

    drop table #temp_StartingValuesBaseData

    Cheers,

  • That's worked. Thanks a lot.

    Jason

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

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