Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 parse hierarchy column to unique id

Author  Topic 

mcolli01
Starting Member

2 Posts

Posted - 2012-09-04 : 11:30:55
I have a column that consists of table name, column name and if column will be as a menu then it will show values.

The rules are:
Table names are 0 indented.
Column names are 3 leading left indented.
Data values are 6 leading left indented.

I would like to uniquely indentify each record as shown below. I have attempted using substring but was hoping someone could point me in the right direction. I could be making this more difficult than it needs to be. This is my data and the project "new identity column example.

Any help is appreciated very much! Thanks in advance! MC

Actual Data New Identity Column
--------------------------------------------------------------------------------------------------------
DIRECTIONAL_DRILL, point, "DIRECTIONAL DRILL", 5, seconds, 1, Code Table1
"LOCATION", menu, required, "LOCATION", required Table1Column1
"BEGIN" Table1Column1Value1
"END" Table1Column1Value1
"COMMENT", text, 100, normal, "COMMENT", normal Table1Column2

DRAIN_TILES, point, "DRAIN TILE", 5, seconds, 1, Code Table2
"IS THIS ON THE CL?", menu, required, "IS THIS ON THE CL?", required Table2Column1
"YES" Table2Column1Value1
"NO" Table2Column1Value2
"BEGIN_OR_END", menu, normal, "BEGIN_OR_END", normal Table2Column2
"BEGIN" Table2Column2Value1
"END" Table2Column2Value2
"Type", menu, required, "Type", normal Table2Column3
"PVC" Table2Column3Value1
"TERRA COTTA CLAY" Table2Column3Value2


Thanks!
MC

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-05 : 21:42:56
is the format consistent?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mcolli01
Starting Member

2 Posts

Posted - 2012-09-06 : 09:58:10
Yes, the format is consistent. We are treating Codes similar to table, Subcodes are similar to columns and the Domains are values inserted for the Code and Subcode. If there is 0 indented left space, then it is a Code, if there is 3 indented left space then it is a Subcode and if 6 indented left space then this is the domain value for the corresponding Code and Subcode.

Thanks!
MC
Go to Top of Page
   

- Advertisement -