2009年7月24日星期五

drop table if exists in SQL Server

/* check if a table already exits before we drop it*/
IF EXISTS(SELECT name FROM sys.tables
WHERE name = 'Table_TempForTest')
BEGIN
/* drop table */
DROP TABLE Table_TempForTest
END
GO

/* see all the tables */
select * from sys.tables

没有评论: