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.
Author |
Topic |
lemondash
Posting Yak Master
159 Posts |
Posted - 2010-10-21 : 09:24:29
|
Good morning or afternoon all.Any help with this would be great. I have a flat table that has hierarchical fields of:[ID],[Name],[ParentID] But the guy that worked here before made the [ID] and [Parent ID] varchar(30) columns and the values are a mixture of letters and number, example 001200000061pObAAII would like to write a query that would output the data with the intent of the parent child relationship. I’m quite capable of doing this if the values were just numbers and the field’s data was int. |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-10-21 : 12:11:14
|
quote: Originally posted by lemondash <snip> I’m quite capable of doing this if the values were just numbers and the field’s data was int.
How does the data type affect your ability to write a query to get the results you want? It should be the exact same query whether the data type is INT or VARCHAR, no? |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-21 : 12:11:52
|
Need to post some sample data.PBUH |
 |
|
michael.appleton
Posting Yak Master
160 Posts |
Posted - 2010-10-21 : 12:26:17
|
Perhaps the data type something like that so it describes it's hierarchy in some way, much like the SQL 2008 new hierarchyId datatype works. Just a guess, as it seems a strange type of id to use. Perhaps there's some custom functions knocking about that the old guy made? |
 |
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2010-10-22 : 04:56:27
|
Here is the example of the data.ID ParentID Name0012000000QIy27AAD NULL Company GROUP0012000000QIySCAA1 0012000000QIy27AAD Company - Main0012000000QIyLZAA1 0012000000QIy27AAD Company - Main |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-10-22 : 13:26:50
|
Just write a query like you would if the ID and ParentID were integers. They query will work just the same. |
 |
|
glendcruz
Yak Posting Veteran
60 Posts |
Posted - 2010-10-24 : 01:56:45
|
I like to know what is the result you require- a sample of it |
 |
|
|
|
|