0
我需要從具有用戶定義表類型的存儲過程對錶進行批量更新。更新導致表鎖定,我想減輕這一點。我想批量他們的1000更新的代碼看起來如下SQL Server批量更新,用戶定義的表類型
CREATE PROCEDURE [dbo].[updatestuff]
@update1 AS udtupdate1 READONLY ,
@update2 AS udtupdate2 READONLY ,
@time DATETIME
AS
BEGIN
SET NOCOUNT ON
-- uses udtupdate1
UPDATE lms
SET lms.col1 = lsp.col1 ,
lms.TimeStamp = @time
FROM dbo.tlivetable1 lms
INNER JOIN @update1 lsp ON lms.livetable1Id = lsp.colId
UPDATE ms
SET ms.col1 = lsp.col1 ,
ms.TimeStamp = @time
FROM dbo.tmrks ms
INNER JOIN @update1 lsp ON ms.mrksId = lsp.Colid
-- uses udtupdate2
UPDATE mms
SET mms.col2 = msp.col2 ,
mms.Date = @time
FROM dbo.tMMSel mms
INNER JOIN @update2 msp ON msp.col1Id = mms.MMId
AND msp.col2Id = mms.MMSId
END
任何幫助將非常感激
Thankyou爲此,我會測試並讓你發佈 – Jdem