Check for the existence of a sql temp table
Here's an easy way to check if a temp table exists, before trying to create it (ie. for reusable scripts) from Simon Sabin's post :
IF object_id('tempdb..#MyTempTable') IS NOT NULL
DROP TABLE #MyTempTable
CREATE TABLE #MyTempTable
ID int IDENTITY(1,1),
That way, if you have to change databases in the query window, you don't have to drop the tables before you run it again.