111,120
社区成员
发帖
与我相关
我的任务
分享if exists(select * from tableName where name='b')
drop table tableNameCreate 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
Goif exists(select 1 from a where name='b')
drop table b
goif exists(select top 1 1 from a where name='b')
drop table b
go