Unanswered: Use value from one select within a stored procedure
How do you use the value of one select statement within another select statement inside the same stored proc?
Here is my scenario: I need a row id from one select statement to make another select statement. I figured instead of making two calls from within my code I could just call one stored procedure which would have to be faster!
I have written plenty of select statement sp's but this is the first time I ever needed to do something like this.
Using your example I came up with this, but it didn't work.
SELECT person_row_id,last_name, first_name, SSN
FROM t_person a
WHERE ssn = '123456789'
AND EXIST(select address_1, address_2, city,state_province, client_employee_id
from t_person_by_service b where person_row_id = a.person_row_id)
I'mnot sure if that helps you understand what I am trying to do, but if it does, what I am looking for in a perfect world would be to return this as one table, not two