Home >

SQL native HierarchyID

23. October 2009

Okay quick blog for today. Not my best, but I have been working with SQL's native HierarchyID type and didn't want to see the regular Hex of 0X5B6EAD6B, So by adding a simple .ToString() on my Select statement for my table I was able to change it to be "/1/2/13/"

 

SELECT TOP 1000 [WidgetInstanceID]

      ,[ParentWidgetInstanceID]

      ,[WidgetTemplateID]

      ,[WidgetInstanceHierarchyID].ToString() as WidgetHiearchyID

  FROM [SrsWebPlatform].[dbo].[WidgetInstance]

 

Which gave me my results of:

WidgetInstanceID ParentWidgetInstanceID WidgetTemplateID WidgetHiearchyID WidgetInstanceLevel

1001                          1022                          1026                     /1/2/13/                      3

 

If you don't know about the HiearchyID in SQL Server 2008 you can read more about it here: 

http://www.sqlservercentral.com/articles/SQL+Server+2008/62204/

 

Off to go SCUBA dive this weekend. Take care!

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview
Loading