Question
When writing a T-SQL script that I plan on re-running, often times I use temporary tables to store temporary data. Since the temp table is created on the fly, I'd like to be able to drop that table only if it exists (before I create it).
I'll post the method that I use, but I'd like to see if there is a better way.
Answer
If Object_Id('TempDB..#TempTable') Is Not Null
Begin
Drop Table #TempTable
End
< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/2649/" >What's the best way to determine if a temporary table exists in SQL Server?< /a>
0 comments:
Post a Comment