Hi Reddy, T ,
Welcome to Microsoft Q&A platform and thanks for posting your question here.
As I understand your question, you are trying to get the level for the employees based on their hierarchy. However, you want the query to be dynamic where column numbers should be based on the level of employees.
You can make use of CTE(common table expression) and perform a self join for the emp table in order to create the hierarchy levels like below:
This would give the hierarchy in a single output column 'empLevel' . It still needs to be modified to make it dynamic to split the values into multiple columns .
I will update you for the dynamic part after I work on it. Hope it helps. Thankyou