MERGE [dbo].[LongTermMemories] AS T
    USING (VALUES (@Key, @Value)) AS S([Key], [Value])
    ON T.[Key] = S.[Key]
    WHEN MATCHED THEN
UPDATE
    SET T.[Value] = S.[Value]
    WHEN NOT MATCHED THEN
INSERT
(
[Key],
[Value])
VALUES (S.[Key], S.[Value]);
