Showing posts with label Temporary table. Show all posts
Showing posts with label Temporary table. Show all posts

Tuesday, July 11, 2017

How to check a temporary table exists in SQL Server

Use this sql query
 IF OBJECT_ID('[Your_DB_Name..#[Temp_Table_Name]') IS NOT NULL   
 BEGIN  
      --Action--
 END  

Example
 IF OBJECT_ID('tempdb..#tempDoc') IS NOT NULL   
 BEGIN  
      Drop Table #tempDoc  
 END