For a client I created resource pool request excel sheet. The purpose was to allow PMs to request for new resources in Project Server. They have not been using Active Directory for automatic resource addition. In that sheet I had couple of columns one was the RBS. I filled out rest of the fields manually as the data was less. But for RBS it was difficult to do that manual work. The following query helped to get the ordered RBS structure for that excel sheet.
Following query gives you the RBS data for documentation needs.
Select CODE_UID, OC_CACHED_FULL_NAME
From MSP_OUTLINE_CODES
Where OC_Cached_Full_Name like ‘TopRBSLevel%’
AND proj_id = 289
Order By CODE_UID
— Replace TopRBSLevel with the top RBS level of your Project Server environment.
(Check with your SQL DBA)