Welcome to Sudeep Pandey

Just for sharing ideas and knowledge— My Blog

Archive for the ‘SQL Server’ Category

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

Posted in SQL Server | Leave a Comment »