In this SQL Tutorial I will show you how to using SQL Server check if temp table exists and drop it if it does.
SQL Server allows you to create #temp tables (# = local temp table) that exist for your connection only. There are advantages of using temp tables over table variables and vice versa but I won't be going into the details here.
I will use SQL Server 2008 R2 for this tutorial but it should work with SQL Server 2005 and 2012.
Below is full example that checks if temp table objects exists and if it does it drops it.
IF object_id('tempdb..#TableName') IS NOT NULL
DROP TABLE #TableName
CREATE TABLE #TableName (FieldName VARCHAR(100))
That is all you need to do to check if temp table exists, drop it and create it again.
I hope this SQL tutorial will help you with your T-SQL development.