Home Forums SQL Server 2005 T-SQL (SS2K5) Select statements included within a function cannot return data to a client RE: Select statements included within a function cannot return data to a client

  • You need to assign the returning value from the select to the variable you declared.

    Like that :

    DECLARE @var nvarchar(200)

    select @var = top 1 field1 from table1

    return @Var.

    That will fix your problem, but I think you should use an Inline function for that, just do this :

    create function fn1

    @Param nvarchar(100)

    returns nvarchar(200)

    as

    BEGIN

    Return (Select top 1 field1 from table1 where Field2 = @Param)

    END

    Hope it helps, if you need some working code, just tell me, I only put sample for you to understand.

    Cheers,

    J-F