Wednesday, March 21, 2012

DROP TABLE IF EXISTS (not working)!

I need to drop a table if exist ?? how can i do that ??
thanx !if object_id('<table_name>') is not null drop table <table_name>|||Originally posted by ms_sql_dba
if object_id('<table_name>') is not null drop table <table_name>

thanx !!!!|||The M$ way...

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Company]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Company]
GO

No comments:

Post a Comment