0

I create this function

ALTER FUNCTION [dbo].[FxPackageReport]
( @packageId int )
RETURNS table
AS
RETURN (
        select *from TestPackageReportDetails where TestPackageId=@packageId and step='LineCheck'
         )
select *from dbo.fxpackagereport(5457)

The result :

enter image description here

I want to merge this columns inside my select something like this :

select id,select *from dbo.fxpackagereport(id), from testpackage

Is there any solution to merge this result with my query >?I just want to bring the table result inside my query .

Ehsan Akbar
  • 6,977
  • 19
  • 96
  • 180
  • Possible duplicate of [SQL Join table-valued function with table where table field is a function input](http://stackoverflow.com/questions/4764994/sql-join-table-valued-function-with-table-where-table-field-is-a-function-input) – AHiggins Aug 31 '16 at 15:40

1 Answers1

2

The UDF seems rather straight forward so rather than using the UDF, a simple join may due.

   Select A.*
          ,B.* 
    From testpackage A
    Join TestPackageReportDetails B
      on (TestPackageId=A.ID and step='LineCheck')

Another option would be to use a CROSS APPLY and your UDF

select A.id
      ,B.*
from testpackage A
Cross Apply (Select * from dbo.fxpackagereport(A.id)) B
John Cappelletti
  • 79,615
  • 7
  • 44
  • 66