SQL 2005 query with dynamic table generation -
SQL 2005 query with dynamic table generation -
i have problem , i'm not sure of best way solve or efficient way handle it. need query database contains supervisors , employees need able go downwards many levels user asks for. mean, query take in 2 primary params, originating employee , how many levels search through. query start looking employees study originating employee , homecoming list of these employees. level 1 search. if user passes through value 2, need employees study employees selected in first list. if user passes value 3, not first level employees, second, employees study employees listed in sec query. in mind have create new table each 1 of these queries in end combine results returned 1 table. right approach? if so, what's best way create clean these tables?
the table beingness searched pretty simple structure:
id employeeid supervisor --- ---------- ---------- 1 harlow, bill foster, sam 2 foster, sam jenkins, alex 3 jenkins, alex wadley, mike
the first query pretty simple:
select id dbo.employees supervisor = 'foster, sam'
sql sql-server-2005
Comments
Post a Comment