----调用举例--------------------------------------------------------------------------
create table dbo.groups
(
group_id int,
group_name varchar(50),
group_father_id int
)
declare @loop as int
set @loop =1
while @loop < 1000
begin
insert into groups (group_id,group_name,group_father_id) values (@loop,'name',@loop -1)
set @loop =@loop +1
end
set @loop =2001
while @loop < 2500
begin
insert into groups (group_id,group_name,group_father_id) values (@loop,'name',@loop -1)
set @loop =@loop +1
end
select * from groups
select * from f_get_data_by_recursion(2001)
drop table dbo.groups
drop function dbo.f_get_data_by_recursion