if (select count(*) from sysobjects where name='aaa')>0 drop proc aaa create proc aaa ( @user_id char(10) ) as begin delete from users where user_id=@user_id and (select * from table2 where user_id=@user_id) is not null if @@rowcount=0 select 'no' else select 'yes' end
drop proc aaa
create proc aaa
(
@user_id char(10)
)
as
begin
delete
from users
where user_id=@user_id and
(select * from table2 where user_id=@user_id) is not null
if @@rowcount=0
select 'no'
else
select 'yes'
end