• lanky_doodle - Thursday, May 3, 2018 5:39 AM

    Hello,

    Is there anyway I can replicate this within an INSERT/OUTPUT statement:

    declare @ID as table(ID uniqueidentifier);

    insert intotbl_Link_Update_History

    outputinserted.ID into @ID

    values(newid(), @LinkID, getdate(), @user-id);

    selectdbo.fnc_FormatDate(luh.Updated_Date, 106) + ' (' + u.Forename + ' ' + u.Surname + ')'

    fromtbl_Link_Update_History luh join

    tbl_Users u on u.[User_ID] = luh.Updated_By_ID

    whereluh.ID =

    (

    selectID

    from@ID

    );

    The needed result is a scalar value: 1 January 1900 (Firstname Lastname)

    Thanks

    And now that I look a little closer, you have a different kind of problem.   You are expecting to limit a query result to values in a table that is only getting inserted into by the output of that very query.   It's NEVER going to work.  I'm not even sure what you think the result of this will be....

    EDIT: I have to retract this... I missed the values clause and that matters.  Just change the = to IN and you should be good to go, assuming that the other tables do have data in them that match the criteria specified.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)