create proc indata @count int=5,@tablename varchar(10) as begin if(@tablename='source_1') begin insert into target_1 select top(@count) id,name,sex,dept,sal from source_1 where id >(select max(id) from node where 表名='source_1') order by id insert into node select (select max(id) from node where 表名='source_1'),'source_1' end else begin insert into target_2 select top(@count) id,name,sex,dept,sal from source_2 where id >(select max(id) from node where 表名='source_2') order by id insert into node select (select max(id) from node where 表名='source_2'),'source_2' end end试试吧,没测试...
create proc indata @count int=5,@tablename varchar(10)
as
begin
if(@tablename='source_1')
begin
insert into target_1
select top(@count) id,name,sex,dept,sal from source_1
where id >(select max(id) from node where 表名='source_1') order by id
insert into node
select (select max(id) from node where 表名='source_1'),'source_1'
end
else
begin
insert into target_2
select top(@count) id,name,sex,dept,sal from source_2
where id >(select max(id) from node where 表名='source_2') order by id
insert into node
select (select max(id) from node where 表名='source_2'),'source_2'
end
end试试吧,没测试...