帮忙小小的改造一下这个存储过程,谢谢
现在的存储过程是这样的
create PROCEDURE dbo.sp_vd_VideoInfo_relate
@id int
AS
declare @ss varchar(50)
select @ss=keywords from dbo.vd_VideoInfo where id=@id
declare my_cursor cursor scroll dynamic /*scroll表示可随意移动游标指针(否则只能向前),dynamic表示可以读写游标(否则游标只读)*/
for
select * from dbo.f_SplitList (',',@ss)
open my_cursor
declare @name sysname
fetch next from my_cursor into @name
while(@@fetch_status=0)
begin
--插入数据
INSERT INTO vd_relate(id,relateid) select @id,id from dbo.vd_VideoInfo where ','+keywords+',' like '%,'+@name+',%'
fetch next from my_cursor into @name
end
close my_cursor
deallocate my_cursor
--去掉本身的新闻id
select distinct * from vd_relate where id<>@id
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
这个存储过程是根据传递过来的参数id,来查找新闻表lc_newsinfo这一条,然后生成她相关的新闻的,放入vd_relate表中,其中里面用到的SplitList函数就不用管它先
我现在要改造成,不要输入参数了,直接把这个新闻表lc_newsinfo循环一遍,然后一条一条生成,因为我要定义成一个作业然它自动运行呢,所以要这么改造,谢谢