How to delete records from a custom inventory table for single resource

book

Article ID: 180957

calendar_today

Updated On:

Products

Inventory Solution

Issue/Introduction

I am testing a custom inventory, and the default behavior is to not reload matching data. How can I remove or delete records for a given resource from a custom inventory table?

Resolution

If you only want to delete data for one resource, the following query can help. To delete records for a single resource from a custinv table:

-- @rguid is the _resourceguid for the client computer
-- @dcguid is the dataclass guid. It can be found in various ways, including:
--    select * from dataclass where name = '<dataclass name>'
DECLARE @rguid varchar(36)
DECLARE @dcguid varchar(36)
DECLARE @custtablename varchar(256)

set @rguid = ‘???’
set @dcguid = '???'
set @custtablename = ‘???’

delete from @custtablename where _resourceguid = @rguid
delete from resourceupdatesummary 
  where resourceguid = @rguid 
    and inventoryclassguid = @dcguid