• You need to encapsulate the SQL text in single quotes as below.

    CREATE FUNCTION dbo.ExecuteStringAsQuery

    (@empID as nvarchar(500))

    RETURNS Varchar(8000)

    AS

    BEGIN

    DECLARE @sqlquery AS NVARCHAR(500),

    @RESULT AS NVARCHAR(500)

    /* Build Transact-SQL String with parameter value */

    SET @sqlquery = '(select JoinDateQuery from NewHireEmployee where empid=' + @empID + ');'

    @RESULT = Execute @sqlquery

    return @RESULT

    END

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg