在 Transact-SQL 和存储过程方面不那么强。我想知道该程序将数据保存在哪里?
ALTER PROCEDURE [dbo].[InsurerCascoConditionsSave]
@InsurerID int
,@Data xml
AS
BEGIN
declare @DocHandle int
EXEC sp_xml_preparedocument @DocHandle OUTPUT, @Data
MERGE InsurerCascoConditions AS target
USING (SELECT InsurerConditionID, @InsurerID, CascoConditionID, Value
FROM OPENXML (@DocHandle, '/DocumentElement/Table1', 2)
WITH (InsurerConditionID int, CascoConditionID int, Value nvarchar(max)))
AS source (InsurerConditionID, InsurerID, CascoConditionID, Value)
ON (target.ID = isnull(source.InsurerConditionID, 0))
WHEN MATCHED THEN
UPDATE SET Value = source.Value
WHEN NOT MATCHED THEN
INSERT (InsurerID, CascoConditionID, Value)
VALUES (source.InsurerID, source.CascoConditionID, source.Value);
EXEC sp_xml_removedocument @DocHandle
END