sqlserver2005 存储过程
2个回答
展开全部
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
create proc [dbo].[P_Del_b]
(
@b_id int
)
as
begin
delete from b where id = @b_id
declare @id int
declare @Project varchar(50)
declare se_isnull cursor for
select id,Project from a
open se_isnull
fetch se_isnull into @id,@Project
while(@@fetch_status = 0 )
begin
declare @beginlen int
declare @rpstrlen int
declare @tmpstr varchar(50)
set @beginlen = charindex(cast(@b_id as varchar(5)),@Project)
if ( @beginlen <> 0)
begin
set @rpstrlen = len(@b_id)
set @tmpstr = stuff(@Project,@beginlen,@rpstrlen+1,'')
update a set Project = @tmpstr where id = @id
end
fetch se_isnull into @id,@Project
end
close se_isnull
deallocate se_isnull
end
set QUOTED_IDENTIFIER ON
go
create proc [dbo].[P_Del_b]
(
@b_id int
)
as
begin
delete from b where id = @b_id
declare @id int
declare @Project varchar(50)
declare se_isnull cursor for
select id,Project from a
open se_isnull
fetch se_isnull into @id,@Project
while(@@fetch_status = 0 )
begin
declare @beginlen int
declare @rpstrlen int
declare @tmpstr varchar(50)
set @beginlen = charindex(cast(@b_id as varchar(5)),@Project)
if ( @beginlen <> 0)
begin
set @rpstrlen = len(@b_id)
set @tmpstr = stuff(@Project,@beginlen,@rpstrlen+1,'')
update a set Project = @tmpstr where id = @id
end
fetch se_isnull into @id,@Project
end
close se_isnull
deallocate se_isnull
end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询