This code will create a custom report, accessible through Orders>Reports>Custom Report. The report will be titled "Output categories", but you can change that to anything you want in the SQL command. The first code set is for the store category ids, and the second set is for exporting manufacturer category ids. We use these for setting up coupons.

To load this into your dashboard, go to Configuration>Advanced>Run SQL. Paste it in and then go to your custom report section.

Code:
INSERT INTO CustomReport (Name, Description, SQLCommand)
VALUES ('Output categories', 'output category structure', 'WITH Categories (ParentCategoryID, CategoryID, Name, ComputedLevel, Sort) AS
(SELECT c.ParentCategoryID, c.CategoryID, c.Name, 0 AS ComputedLevel, CAST(c.Name AS NVARCHAR(255)) + '' ('' + CAST(c.CategoryID AS NVARCHAR(10)) + '')''
FROM Category AS c
WHERE ParentCategoryID = 0
AND Deleted=0
AND Published=1
UNION ALL
SELECT c.ParentCategoryID, c.CategoryID, c.Name, ComputedLevel + 1, CAST(s.Sort + '' > '' + c.Name AS NVARCHAR(255)) + '' ('' + CAST(c.CategoryID AS NVARCHAR(10)) + '')''
FROM Category AS c
INNER JOIN Categories AS s ON c.ParentCategoryID = s.CategoryID
WHERE Deleted=0
AND Published=1)

SELECT ParentCategoryID, CategoryID, Name, ComputedLevel, Sort
FROM Categories
ORDER BY 5')
For manufacturer category IDs:

Code:
INSERT INTO CustomReport (Name, Description, SQLCommand)
VALUES ('Output manufacturer categories', 'output manufacturer category structure', 'WITH Manufacturers (ParentManufacturerID, ManufacturerID, Name, ComputedLevel, Sort) AS
(
SELECT c.ParentManufacturerID, c.ManufacturerID, c.Name, 0 AS ComputedLevel, CAST(c.Name AS NVARCHAR(255)) + '' ('' + CAST(c.ManufacturerID AS NVARCHAR(10)) + '')''
FROM Manufacturer AS c
WHERE ParentManufacturerID = 0
AND Deleted=0
AND Published=1
UNION ALL
SELECT c.ParentManufacturerID, c.ManufacturerID, c.Name, ComputedLevel + 1, CAST(s.Sort + '' > '' + c.Name AS NVARCHAR(255)) + '' ('' + CAST(c.ManufacturerID AS NVARCHAR(10)) + '')''
FROM Manufacturer AS c
INNER JOIN Manufacturers AS s ON c.ParentManufacturerID = s.ManufacturerID
WHERE Deleted=0
AND Published=1
)

SELECT ParentManufacturerID, ManufacturerID, Name, ComputedLevel, Sort
FROM Manufacturers
ORDER BY 5')
This code is courtesy of member esedirect. Thank you!