USE [DataPRO] GO /****** Object: StoredProcedure [dbo].[sp_CustomerDetailsDelete] Script Date: 3/14/2019 3:29:46 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_CustomerDetailsDelete] @Name nvarchar(255) = null ,@errorNumber int output ,@errorMessage nvarchar(250) output AS BEGIN SET NOCOUNT ON; set @errorNumber = 0 set @errorMessage = space(0) declare @CustomerId int set @CustomerId = dbo.foo_IdGetCustomer(@Name) UPDATE [dbo].[TestSetups] SET CustomerId = null WHERE CustomerId = @CustomerId delete from [dbo].[CustomerDetails] WHERE @Name is null or [CustomerId] = @CustomerId END