I have a lot of research on how to set up a query in sql server but I have not been very successful.
First, I have a system that controls an industrial courtyard in which there are organizational levels and I have the structure that has the name of the sector. The organizational can increase or decrease depending on demand and structure has a one-to-many relationship with itself.
Eg:
> Organizacional {[Id: 1, Nm: Administracao], [Id: 2, Nm: Carregamento], > [Id:3, Nm: Descarga], ...} > > Estrutura {[Id: 1, Nm: XPTO, Organizacional_Id: 1], [Id: 2, Nm: > Sementes, Organizacional_Id: 2], [Id: 3, Nm: Animal, > Organizacional_Id: 2], [Id: 4, Nm: XPTO4, Organizacional_Id: 1], [Id: > 5, Nm: Semente, Organizacional_Id: 3], ...}
Well, I would like to know if it is possible to do a recursive query where the result would be structure and the column names would be provided by organizational
Ex:
> [Organizacional.Nm]+'_Id',[Organizacional.Nm]+'_Nm' Estrutura.Id > , Estrutura.Nm
and so on.