我有一种情况需要从表中检索记录并使用这些值并作为存储过程的参数传递。存储过程将重新运行一行,我需要再次使用存储过程返回的值并更新其他表。请给我一个示例C#代码来实现这个场景。任何帮助都会被挪用。
先谢谢,
与Pradeep
答案 0 :(得分:0)
你可以试试这个:
createPROCEDURE MultipleTransaction
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @a int;
set @a=1;
-- Insert statements for procedure here
while((select distinct id from a where id =@a) is not null )
begin
declare @name varchar(100)
declare @id int
set @name =(select distinct name2 from a where id =@a)
set @id =(select distinct id from a where id =@a)
exec GetRows @name,@id -- calling another procedure
set @a =@a+1;
end
END
create PROCEDURE GetRows
(@Para varchar(100),@id varchar(10) )
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
UPDATE [Cube].[dbo].[b]
SET [name1] = @Para
WHERE id =@id
END