Forum Discussion
MikekSSL
8 years agoFrequent Visitor
HierarchyID display
Hello I have a table with a standard Microsoft hierarchyID column positioning parts with a product Bill of Materials. I can display the BoM parts in Excel tabbomng across and back for each level us...
Greg_Deckler
8 years agoCommunity Champion
Not entirely, what would an actual row of data look like? I don't need your data, just a representation of a data row.
MikekSSL
8 years agoFrequent Visitor
Run this
DECLARE @tab CHAR(2)
SET @tab = CHAR(9)
SELECT
Convert(nvarchar(100),REPLICATE(@tab , b.OrganizationNode.GetLevel()) )
+ b.LoginID + '--- '
+ Convert(nvarchar(25),b.OrganizationNode.GetLevel() )
as listing
FROM [HumanResources].[Employee] AS b
order by OrganizationNode
#
The output is a single column - with a number of tabs before teh text. If you output to file and load into Excel the tabs will spread the text across the XLS, one column of each tab.
The raw data is exactly as you'll see if you do a select * from AdventureWorks2014.HumanResources.Employee