34,588
社区成员
发帖
与我相关
我的任务
分享
use r5
-- 建存储过程
create proc dbo.Call_r6test1
(@z1 as t_table_type readonly)
as
begin
if object_id('tempdb..#z1') is not null
drop table #z1
select * into #z1 from @z1
declare @tsql nvarchar(max)
select @tsql=N'use r6;
declare @z1 as t_table_type;
insert into @z1 select * from #z1;
exec test1 @z1;'
exec(@tsql)
end
-- 测试
declare @z1 AS t_table_type
insert into @z1
select 1,'2','3' union all
select 4,'5','6'
exec dbo.Call_r6test1 @z1
/*
id name sex
----------- -------------------------------- ----
1 2 3
4 5 6
(2 行受影响)
*/