27,582
社区成员




update spbm set pybm=@npy where spbm=@cid
create trigger pybm on spbm
for insert,update
AS
declare @name varchar(100),@npy varchar(100),@cid char(11)
if(update(spmc))
begin
declare spmclist cursor forward_only
for select spmc,spbm from inserted
open spmclist
fetch next from spmclist into @name,@cid
while(@@fetch_status<>-1)
begin
set @npy=''
exec Hz2Py @name,@npy output
update spbm set pybm=@npy where spbm=@cid
fetch next from spmclist into @name,@cid
end
close spmclist
deallocate spmclist
end
GO
create trigger pybm on spbm for insert,update
AS
declare @name varchar(100),@npy varchar(100),@cid char(11)
if(update(spmc)) begin
DECLARE cur_rec CURSOR LOCAL SCROLL FOR
select spmc,spbm from inserted
OPEN cur_rec
FETCH NEXT FROM cur_rec INTO @name,@cid
WHILE (@@fetch_status <> -1)
BEGIN
set @npy=''
exec Hz2Py @name,@npy output
update spbm set pybm=@npy where spbm=@cid
FETCH NEXT FROM cur_rec INTO @name,@cid
END
CLOSE cur_rec
DEALLOCATE cur_rec
end
GO
--try
update a set pybm=@npy from spbm a join inserted i on a.spmc=i.spmc and spbm=@cid
create trigger pybm on spbm for insert,update
AS
declare @name varchar(100),@npy varchar(100),@cid char(11)
DECLARE @Table TABLE(ID INT IDENTITY(1,1),name VARCHAR(100),cid INT)
DECLARE @Total INT
DECLARE @Line INT = 1
if(update(spmc)) begin
set @npy=''
INSERT INTO @Table
select spmc,spbm from inserted
SELECT @Total = MAX(ID) FROM @Table
WHILE @Line <= @Total
BEGIN
select @name=name,@cid=cid from @Table WHERE ID = @Line
exec Hz2Py @name,@npy output
update spbm set pybm=@npy where spbm=@cid
SET @Line = @Line + 1
END
end
GO