Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7847797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:00:17+00:00 2026-06-02T18:00:17+00:00

I’m using SQL Server 2008. Here is what I’m trying to do. I have

  • 0

I’m using SQL Server 2008. Here is what I’m trying to do. I have a table with marketgroupID and parentID. each marketgroup has a name. I’d like to create the hierarchy path of those names.

I tried the CTE solution with a WITH anchor_statement recursive_statement, select. it didn’t work.

I found another solution where you create a new table, and fill in the values iteratively. It’s not the most performant, it duplicates lots of data and columns, but i don’t really care because it’s more or less a one time process on a relatively small database. I’m just looking for a simple solution (like everyone I guess)

Basically, I successfully created the table and copied some values inside of it.

--Create Lineage Table
Create Table Eve.dbo.invLineage(
Node int NOT NULL IDENTITY(100,1),
typeID int,
parentNode int,
marketGroupName nvarchar(100),
marketGroupID int,
Depth tinyint,
Lineage nvarchar(max)
)

and copied values into it.

INSERT INTO EVE.dbo.invLineage ( typeID,marketGroupID)
SELECT [EVE].[dbo].invTypes.typeID,EVE.dbo.invTypes.marketGroupID
FROM EVE.dbo.invTypes
LEFT JOIN eve.dbo.invGroups ON EVE.dbo.invTypes.groupID= eve.dbo.invGroups.groupID
WHERE eve.dbo.invGroups.categoryID=7 AND Eve.dbo.invTypes.published=1

this is an exemple of the result I get at this stage:

 Node   typeID   parentNode marketGroupName marketGroupID Depth Lineage
 100    377      NULL       NULL            605           NULL  NULL
 101    380      NULL       NULL            605           NULL  NULL
 102    393      NULL       NULL            126           NULL  NULL
 103    394      NULL       NULL            126           NULL  NULL
 104    399      NULL       NULL            609           NULL  NULL
 105    400      NULL       NULL            609           NULL  NULL
 106    405      NULL       NULL            604           NULL  NULL
 107    406      NULL       NULL            604           NULL  NULL

So I managed to get a nodeID, a typeID, and a marketGroupID successfully. sorry for the bad display in here, I’m still learning the forums.

Now, I’d like to update the parentNode for each row of the Lineage table.

This information is a column in the marketGroup table.

Here is the request I wrote but that returns 0 rows.

UPDATE T SET T.parentNode=P.Node
FROM Eve.dbo.invLineage as T 
INNER JOIN eve.dbo.invMarketGroups E ON T.marketGroupID=E.marketGroupID
INNER JOIN eve.dbo.invMarketGroups B ON E.parentGroupID=B.marketGroupID
INNER JOIN Eve.dbo.invLineage P ON B.marketGroupID=P.marketGroupID

The first 2 inner joins seems to work fine, but the last one makes it return 0 rows.

Also, I’m following this handy guide : http://www.sqlteam.com/article/more-trees-hierarchies-in-sql

Here are some results i get if i run this select query for debug purpose:

SELECT * --SET T.parentNode=P.Node
FROM Eve.dbo.invLineage as T 
INNER JOIN eve.dbo.invMarketGroups E ON T.marketGroupID=E.marketGroupID
INNER JOIN eve.dbo.invMarketGroups B ON E.parentGroupID=B.marketGroupID
--INNER JOIN eve.dbo.invLineage P ON B.marketGroupID=P.marketGroupID

Node    typeID  parentNode  marketGroupName marketGroupID   Depth   Lineage marketGroupID   parentGroupID   marketGroupName description iconID  hasTypes    marketGroupID   parentGroupID   marketGroupName description iconID  hasTypes
1134    10039   NULL    NULL    760 NULL    NULL    760 9   Civilian Modules    Modules whose specifications are geared toward use on rookie ships. NULL    1   9   NULL    Ship Equipment  Everything the dedicated pilot needs to outfit their ship.  1432    0
2913    21853   NULL    NULL    760 NULL    NULL    760 9   Civilian Modules    Modules whose specifications are geared toward use on rookie ships. NULL    1   9   NULL    Ship Equipment  Everything the dedicated pilot needs to outfit their ship.  1432    0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:00:18+00:00Added an answer on June 2, 2026 at 6:00 pm

    Both your records have B.marketGroupID = 9.

    But your eve.dbo.invLineage table only has marketGroupID IN (605, 126, 209, 604)

    So, in short, you get no records because ON B.marketGroupID=P.marketGroupID never finds any matches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.