📜  t-sql 更新表变量 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:01.439000             🧑  作者: Mango

代码示例1
UPDATE @searchResult
SET [record_id] = r.[record_id], 
    [record_name] = r.[record_name]
FROM @searchResult SR
CROSS APPLY (
    SELECT TOP 1 *
    FROM [records]
    WHERE [record_name] LIKE [name_template]   -- Your wish, but do you really need LIKE matching??
    ORDER BY [record_id] DESC
) AS r;