I have a Location table:
Id int
MasterLocationId int
Name varchar(50)
A location can have a master location and so on. There's no specific limit to how many levels this could be.
How can I search for any locations with a certain ID, or locations where a master record has that ID, or its master record has that ID - and so on.
I'm not really sure what to even search for on Google here - perhaps this type of situation has a name and I'm not sure what it's called?
I've searched for recursive TSQL and couldn't find anything.
Is this possible?
Thanks