USP_STATE_DELETE
Executes the "State: Delete" record operation.
Parameters
| Parameter | Parameter Type | Mode | Description | 
|---|---|---|---|
| @ID | uniqueidentifier | IN | Input parameter indicating the ID of the record being deleted. | 
| @CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the delete. | 
Definition
 Copy 
                                    
CREATE procedure dbo.[USP_STATE_DELETE]
(
  @ID uniqueidentifier,
  @CHANGEAGENTID uniqueidentifier
)
with execute as owner  -- so that sp_executesql will work without having to grant permission to ZIPCITYSTATE
as begin
  set nocount on;
  if object_id('dbo.ZIPCITYSTATE') is not null begin
    -- delete any ZIPCITYSTATE records that were imported (this table is not audited, so we directly delete from it)
    exec sp_executesql N'delete from dbo.[ZIPCITYSTATE] where [STATEID] = @ID', N'@ID uniqueidentifier', @ID = @ID;
  end
  -- delete the state record
  exec dbo.[USP_STATE_DELETEBYID_WITHCHANGEAGENTID] @ID, @CHANGEAGENTID;
  return 0;
end