I want to call a stored procedure in a join statement of the Select Query.
For example,
Select *
from test
left join test1 on GetID(test.id)=test1.id
The idea is to match one to many relationship.
The structure of tables would be
Table: Test
ID Name
1 abc
2 te
Table: Test1
Id TestID Name
1 1 xxx
2 1 yyy
3 1 zzz
4 2 aaa
Stored procedure:
Create procedure GETID
@id int
as
begin
select top 1 id
from test1
where testid = @id
end