In response to Sam Stange's "An old and new way to query Hierarchical data", this script uses the new CTE feature of SQL Server 2005 to display the hierarchical data all at once. I have added a check to prevent infinite loop in case there is a loop in the data (actually, there is one in the example). But this script has some limitations:
1) The maximum number of childern for a parent is 2^33. But you can enlarge this number by expanding the slots in s column (currently, it's 10 characters wide for each level).
2) The maximum number of levels is 100. This is the limitation of T-SQL.
A Normalization Primer
For most DBAs, normalization is an understood concept, a bread and butter bit of knowledge. However, it is not at all unusual to review a database design by a development group for an OLTP (OnLine Transaction Processing) environment and find that the schema chosen is anything but properly normalized. This article by Brian Kelley will give you the core knowledge to data model.
2003-01-13
18,597 reads