Why would you go to db directly?
Create a query to filter based on different paths in the system tree and apply tag with a server task.
Is this because you have a lot of paths ? If so you can easily modify the xml of a query to import those paths.
Thanks!!! But the idea is to assign the same tag to 1000+ desktops in a lot of differents paths. The total park of machines is about 14.000+