有没有办法做到这一点,例如在Transact-sql中使用某种条件运算符?
IF @ParentBinaryAssetStructureId = -1
BEGIN
SET @ParentBinaryAssetStructureId = NULL
END
UPDATE BinaryAssets.BinaryAssetStructures
SET ParentBinaryAssetStructureId = @ParentBinaryAssetStructureId
WHERE BinaryAssetStructureId = @OriginalBinaryAssetStructureId
Run Code Online (Sandbox Code Playgroud)
使用NULLIF()
UPDATE BinaryAssets.BinaryAssetStructures
SET ParentBinaryAssetStructureId = NULLIF(@ParentBinaryAssetStructureId,-1)
WHERE BinaryAssetStructureId = @OriginalBinaryAssetStructureId
Run Code Online (Sandbox Code Playgroud)