´æÔÚ±íb£¬ ÏÖÔÚҪɾ³ý±íb£º drop b£¬µ«Ç°ÌáÊÇÔÚ±íaÖдæÔÚname='b',Óï¾ä¸ÃÔõôд£¿Ò»¾äÍê³ÉŶSQL code: if exists(select 1 from a where name='b') drop table b go
SQL code: Create Table a ( [id] int not null, [name] varchar(80) not null )
Go
Create Table b ( [id] int not null, [name] varchar(80) not null )
Go
Insert Into a([id], [name]) values(1, 'b')
Insert Into a([id], [name]) values(2, 'c')
Go
If Exists(Select 1 from a Where [name] = 'b') Drop Table b
Go
ÓÐT-SQLµÄÂ𣿣¬ÔÚC#ÖÐÖ´ÐеÄ
Õâ¸ö¾Í¿ÉÒÔÔÚC#ÀïÃæÔËÐа¡£¡¸úÖ´ÐÐÆäËüsqlÊÇÒ»ÑùµÄ! SQL code: if exists(select top 1 1 from a where name='b') drop table b go