• sgmunson - Tuesday, May 8, 2018 7:00 AM

    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....

    The only problem I see with the second query is the use of the '=' sign instead of using IN.

    But then again, I could be wrong.