Welcome to Sudeep Pandey

Just for sharing ideas and knowledge— My Blog

Drop table if exist and create table (SQL Server)

Posted by Sudeep Pandey on November 14, 2009

IF EXISTS(SELECT 1 FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(‘table2′) AND type = ‘U’)
DROP TABLE table2
create table table2(lname varchar(20))

Note: type=’U’ means the object type is for table

Leave a Reply

You must be logged in to post a comment.