Hope this est ce que vous cherchez:
declare
asdf number;
begin
for r in (select * from xyz) loop
insert into abc (column1, column2, column3)
values (r.asdf, r.vcxvc, r.dffgdfg) returning id into asdf;
update xyz set column10 = asdf where ID = r.ID;
end loop;
end;
deviendrait
DECLARE @asdf int
DECLARE @ID int
DECLARE @MyTmpTableVar table(asdf int, abc_id int)
// insert records from your cursor r into table abc,
// and return a temporary table with "id" and "asdf" fields from the xyz table
INSERT INTO abc(column1, column2, column3)
OUTPUT asdf, id INTO @MyTmpTableVar
SELECT r.asdf, r.vcxvc, r.dffgdfg
FROM xyz
// if it would return just one row and you wanted to find the value
//SELECT @asdf = asdf, @id = abc_id
//FROM @MyTmpTableVar
// update the table xyz with the values stored in temporary table
// restricting by the key "id"
UPDATE xyz
SET xyz.column10 = t.asdf
FROM @MyTmpTableVar AS t
WHERE xyz.id = t.abc_id
La version sqlServer du La clause de retour dans Oracle est la clause OUTPUT.
S'il vous plaît visitez this msdn page pour une information complète
Davis, s'il vous plaît revenir à l'aide d'un curseur, vous ne devriez pas, si toute utilisation possible un curseur dans sql server, car ils sont extrêmement lents par rapport aux solutions-set. Des solutions basées sur des ensembles ont été fournies et vous devriez les considérer. Puisque vous convertissez à partir d'Oracle, vous devez cesser de penser en termes de boucles et commencer à penser à des ensembles de données lorsque vous travaillez avec SQL Server. – HLGEM