Querying The Result Set of SQL Statement All in One statement
Posted on 2010-01-06
may be its late in the day and my mind is cooked, but I trying to create a stored proc that does the following....
I want to use this sql
SELECT DISTINCT EMPLNM
WHERE EMPLNM like @prefix + '%'
To query the result of this sql...
SELECT DISTINCT cash_EmplList.EMPLNM, cash_EmplList.EMPLID
FROM cash_EmplList INNER JOIN
cash_Role ON cash_EmplList.EMPLID = cash_Role.EMPLID
WHERE (cash_EmplList.RPT_TO_NM = @name) AND (cash_Role.ROLE = @role)
Can some help me write write 1 sql statement that does this...So get the result of the 2nd query first then use the first query to query that result.