lw_deletePerson.sql
If Exists (Select * From sysobjects Where name = N'lw_deletePerson' And user_name(uid) = N'dbo')
Drop Procedure dbo.lw_deletePerson
Go
CREATE Procedure lw_deletePerson (
@personid int
)
As
set nocount on
if exists(select * from personGroup where personid= @personId)
begin
raiserror('Person is asssociated with group. U cannot delete',-1,-1) with nowait
return 1
end
if exists(select * from person where personid=@personid)
begin
delete from person where personid = @personid
return 0
end
else
begin
raiserror('person with %ld personId doesnot exist',-1,-1,@personId) with nowait
return 1
end
Go