cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a way to batch delete Enterprise Structure Locations and Categories?

We would like to restructure how the locations and categories are organized and would like to delete all existing location and category paths to reload new ones.

Is there a simple batch process that can do this since doing individually via the web interface would be too time consuming?

Example would be a stored database routine similar to deleting users in bulk with ComplianceUserRemoveBatch.

 

2 Replies

Hi, 

Please reach out to Support. They can help with providing the SQL. There are SQLs that have been used to perform cleanup for Cloud customers, which can be used for any OnPrem environments too.

Thanks!

Ex-Flexera
ChrisG
Community Manager Community Manager
Community Manager

Here's an example of a SQL script that can be executed against the compliance database to delete all groups identified by the first query in this script:

-- This script will delete all enterprise groups identified by the following query:

SELECT GroupID
INTO #GroupsToDelete
FROM dbo.GroupEX_T
WHERE
	GroupTypeID = 1			-- 1 = locations, 2 = corporate units, 3 = cost centers
	AND BusinessView = 0	-- don't delete the root group

DECLARE db_cursor CURSOR FOR
SELECT GroupID from #GroupsToDelete ORDER BY GroupID

OPEN db_cursor

DECLARE @ID int

FETCH NEXT FROM db_cursor INTO @ID

WHILE @@FETCH_STATUS = 0
BEGIN
	PRINT @ID

	EXEC dbo.GroupDeleteAndChildren @groupid = @ID

	FETCH NEXT FROM db_cursor INTO @ID
END

CLOSE db_cursor
DEALLOCATE db_cursor

 

(Did my reply solve the question? Click "ACCEPT AS SOLUTION" to help others find answers faster. Liked something? Click "KUDO". Anything expressed here is my own view and not necessarily that of my employer, Flexera.)