For small group counts, this should work on MS-SQL 2005
DECLARE @xmlDoc varchar(max)
DECLARE @handle INT;
SET @xmlDoc = ( select convert(varchar(max), convert(varbinary(max), content)) from basic_metadata where type='SemClientGroupTree' );
EXEC sp_xml_preparedocument @handle OUTPUT, @xmlDoc
select ID,Name from identity_map where type='SemClientGroup' and Id not in(
SELECT * FROM OPENXML (@handle, '//*', 1) WITH("Id" VARCHAR(64)) where Name != 'NULL' and Id != 'NULL'
)
EXEC sp_xml_removedocument @handle;