Hi all,
I'm trying to setup a couple of hiearchies in my new SQL Server database. For example Product Categories.
This is the table definition:
The data should look like this:
ProductCategoryID ParentID ProductCategory 1 1 Main category 1 2 2 Main category 2 3 1 Sub1 of Main 1 4 1 Sub2 of Main 1 5 4 SubSub1 of Sub2 6 2 Sub2 of Main 2 7 7 Main category 3 8 7 Sub1 of Main 3 9 9 Main category 4
I would like to assign default Parent for itself when creating a new category, so I create a main category by default.
Something like this:
That clearly doesn't work because I don't know the primary key yet. And it's probably completely wrong statement within the T-SQL language.
Can you please help me how to approach this problem? I wanna do other hiearchies as well, so I'm looking for general concepts.
Thanks a lot in advance.
Best regards,
Tomas