在一个存储过程里如何批量执行下面的增删改操作?最好能举出实例
create myproc
@f1
@f2
@f3
as
if @f1=0
begin
insert t1(f1,f2,f3) values (@f1,@f2,@f3)
end
if @f1=1
begin
update t1 set f1=@f1,f2=@f2,f3=@f3
end
if @f1=2
begin
delete t1
end
GO
...全文
667打赏收藏
如何批量执行存储过程里的增删改操作?
在一个存储过程里如何批量执行下面的增删改操作?最好能举出实例 create myproc @f1 @f2 @f3 as if @f1=0 begin insert t1(f1,f2,f3) values (@f1,@f2,@f3) end if @f1=1 begin update t1 set f1=@f1,f2=@f2,f3=@f3 end if @f1=2 begin delete t1 end GO
create myproc2
as
DECLARE Employee_Cursor CURSOR FOR
SELECT LastName, FirstName FROM Northwind.dbo.Employees
OPEN Employee_Cursor
FETCH NEXT FROM Employee_Cursor
WHILE @@FETCH_STATUS = 0
BEGIN
Exec myproc --调用
FETCH NEXT FROM Employee_Cursor
END
CLOSE Employee_Cursor
DEALLOCATE Employee_Cursor