I'm trying to insert data into a table. If the record already exists, I want to replace the Base64 and keep the existing identifier. If the record doesn't already exist, just insert as normal.
The code at the moment checks if the record exists and either replaces or inserts. I'm getting a syntax error and i'm not entirely sure what I'm doing wrong.
IF EXISTS (
SELECT Bdt_DocumentDataAsBase64.Identifier
FROM Bdt_DocumentDataAsBase64
WHERE Bdt_DocumentDataAsBase64.Identifier = @Identifier
)
BEGIN
(
REPLACE INTO Bdt_DocumentDataAsBase64(Identifier,Base64)
VALUES (@Identifier, @Base64 )
)
END
ELSE
BEGIN
(
INSERT INTO Bdt_DocumentDataAsBase64(Identifier,Base64)
VALUES (@Identifier, @Base64)
)
END
Aucun commentaire:
Enregistrer un commentaire