我有一种情况,我需要从表中检索记录并使用这些值并作为存储过程的参数传递。存储过程将重新运行一行,并且我需要使用存储过程返回的值并更新其他表。请给我一个示例C#代码来实现这种情况。任何帮助都将被占用。需要做与SQLServer数据库的多个事务
由于事先
普拉迪普
我有一种情况,我需要从表中检索记录并使用这些值并作为存储过程的参数传递。存储过程将重新运行一行,并且我需要使用存储过程返回的值并更新其他表。请给我一个示例C#代码来实现这种情况。任何帮助都将被占用。需要做与SQLServer数据库的多个事务
由于事先
普拉迪普
你可以试试这个:
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 [email protected]) is not null)
begin
declare @name varchar(100)
declare @id int
set @name =(select distinct name2 from a where id [email protected])
set @id =(select distinct id from a where id [email protected])
exec GetRows @name,@id -- calling another procedure
set @a [email protected]+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 [email protected]
END
也只是另一种 “Giv'me泽codez” -Questions ... – 2010-10-11 06:55:51