good day I have a query where I use a merge in store procedure I have a screen that has 7 thousand records that I must insert or update, the detail is that the process lasts about 5 minutes and I want to see a way to do the most fast I have the code so:
for (var i=0;i<7000;i++){
var registro1;
var regisro2;
var registro3;
"EXEC test '"®istro1&"','"®istro2&"','"®istro3&"'";
}
my store procedure:
CREATE PROCEDURE Clasificaciones(
@registro1 varchar(7),
@registro2 varchar(18),
@registro3 varchar(2),
)
AS
BEGIN
SET NOCOUNT ON
MERGE tabla as TARGET
USING(SELECT @registro1, @registro2, @registro3) AS SOURCE(registro1, registro2, registro3)
ON (TARGET.registro1 = SOURCE.registro1 AND TARGET.registro2 = SOURCE.registro2)
WHEN MATCHED THEN
UPDATE SET regitro3 = SOURCE.registro3,
WHEN NOT MATCHED THEN
INSERT (registro1,registro2,registro3)
VALUES (SOURCE.regisro1, SOURCE.registro2, SOURCE.registro3);
END
about how is the code then if someone can tell me how it would do something similar that was faster?