为此,您需要添加一个id
要替换的位置Primary key value
例如:<a href="localhost:19763/BitBucket/GUEST/... ?GuestInviteFwd=uArAiAd
并使用以下触发器
CREATE TRIGGER EEmailData_Trigg ON EEmailData
AFTER INSERT
AS
IF EXISTS (SELECT top(1)*
FROM EEmailData p
JOIN inserted AS i
ON p.EEmailDataID = i.EEmailDataID
)
BEGIN
DECLARE @html VARCHAR(MAX),@id INT
SELECT @html=htmlContent ,@id=EEmailData
FROM EEmailData
WHERE EEmailDataID =(SELECT TOP(1) EEmailDataID FROM inserted)
UPDATE EEmailData
SET htmlContent=REPLACE(@html,'uArAiAd',@id)
WHERE EEmailDataID=@id
END
现在触发器uArAiAd
被 EEmailDataID 替换后
你也可以在没有触发器的情况下实现这一点。插入后只需执行以下操作。
DECLARE @html VARCHAR(MAX),@id INT
--insert statements
SET @id=SCOPE_IDENTITY()
SELECT @html=htmlContent ,@id=EEmailData
FROM EEmailData
WHERE EEmailDataID =@id
UPDATE EEmailData
SET htmlContent=REPLACE(@html,'uArAiAd',@id)
WHERE EEmailDataID=@id