My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Delete A Table as well as Temp Table in SQL

Monday, 16 May 2011

2 Ways are there to Delete A Temp Table

1st Way

IF OBJECT_ID('tempdb..#mytemptable') > 0 
    DROP TABLE #mytemptable


2nd Way

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Table]')
                   AND type in (N'U'))


DROP TABLE [dbo].[Table]

No comments:

Post a Comment

 

Blogger news

Blogroll

Most Reading

8.6/10