INNER JOIN between a CLR-TVF and a table returns no rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • h2reyes
    New Member
    • Feb 2007
    • 1

    INNER JOIN between a CLR-TVF and a table returns no rows

    I have the following query:

    select sq.*, p.numero, p.nombre
    from paf p right outer join dbo.GetListOfSq uaresForShippin gLot(@lot) sq on sq.number = p.numero and sq.version = p.numero

    The @lot parameter is declared at the top (declare @lot int; set @lot = 1;). GetListOfSquare sForShippingLot is a CLR TVF coded in C#. The TVF queries a XML field in the database and returns nodes as rows, and this is completed with information from a table.

    If I run a query with the TVF only, it returns data; but if I try to join the TVF with a table, it returns empty, even when I'm expecting matches. I thought the problem was the data from the TVF was been streamed and that's why it could not be joined with the data from the table.

    I tried to solve that problem by creating a T-SQL multiline TVF that is supposed to generate a temporary table. This didn't fix the problem.

    What can I do? Does anybody know if I can force the TVF to render its data somewhere so the JOIN works? I was thinking a rowset function could help, but I just can't figure out how.

    PLEASE HELP!!!!

    Let me know if you want the code for the CLR TVF. This is the code for the T-SQL TVF:

    CREATE FUNCTION [dbo].[GetTabListOfSqu aresForShipping Lot]
    (
    @ShippingLot int
    )
    RETURNS
    @result TABLE
    (
    Number int, Version int, Position smallint,
    SubModel smallint, Quantity smallint,
    SquareId nvarchar(5),
    ParentSquareId nvarchar(5),
    IsSash smallint,
    IsGlazingBead smallint,
    Width float,
    Height float,
    GlassNumber smallint,
    GlassWidth float,
    GlassHeight float
    )
    AS
    BEGIN
    INSERT INTO @result
    SELECT *
    FROM dbo.GetListOfSq uaresForShippin gLot(@ShippingL ot)

    RETURN
    END
Working...