--- 1.创建表类型
create type LocationTableType as Table
(sonum varchar(20)
,itemNum varchar(20)
,itemQty int
,soarea varchar(10))
---2.创建一个存储过程以表值参数作为输入
alter proc usp_TestProcWithTable
@tb LocationTableType READONLY ----表值参数 "@tb" 为只读,无法修改
as
DECLARE @TVP AS LocationTableType;--声明表值参数变量
insert into @TVP(Sonum,ItemNum,ItemQty,soarea) --将数据插入表值变量
select Sonum,ItemNum,ItemQty,soarea from testtb
select * from @TVP
--3.最后执行查询语句如下
DECLARE @AA AS LocationTableType;
EXEC usp_TestProcWithTable @AA;
create type LocationTableType as Table
(sonum varchar(20)
,itemNum varchar(20)
,itemQty int
,soarea varchar(10))
---2.创建一个存储过程以表值参数作为输入
alter proc usp_TestProcWithTable
@tb LocationTableType READONLY ----表值参数 "@tb" 为只读,无法修改
as
DECLARE @TVP AS LocationTableType;--声明表值参数变量
insert into @TVP(Sonum,ItemNum,ItemQty,soarea) --将数据插入表值变量
select Sonum,ItemNum,ItemQty,soarea from testtb
select * from @TVP
--3.最后执行查询语句如下
DECLARE @AA AS LocationTableType;
EXEC usp_TestProcWithTable @AA;