



CREATE PROCEDURE DBO.[DeleteContactPersons] @CustomerNumber int, @Status varchar(1)  AS
SET NOCOUNT ON

declare @LinkCustomerNumber int
declare CustomerLinkCursor cursor for select distinct CustomerLinkNumber from CustomerLinks where (CustomerNumber = @CustomerNumber) and (LinkTypeNumber = 1) 
open CustomerLinkCursor
fetch next from CustomerLinkCursor into @LinkCustomerNumber
while @@fetch_status = 0
begin
--  print  @LinkCustomerNumber
  Update Customer Set  MarkAsDeleted = @Status where CustomerNumber = @LinkCustomerNumber --Mark the Cuatomer As Deleted
--  delete from CustomerLinks where  (CustomerNumber = @CustomerNumber)  and (LinkTypeNumber = 1) --delete the kink
  fetch next from CustomerLinkCursor into @LinkCustomerNumber
end

close CustomerLinkCursor
deallocate CustomerLinkCursor

