最近项目使用到了存储过程传入表类型参数。

--定义表类型

create type t_table_type as table

(

id int,

name varchar(32),

sex varchar(2)

)

 

go

--创建存储过程

CREATE PROC u_test

(@t t_table_type readonly)

as

begin

     select * from @t

    

end

 

--调用存储过程

declare @t t_table_type

 

insert into @t values (1,'a','f')

insert into @t values (2,'a','f')

insert into @t values (3,'a','f')

insert into @t values (4,'a','f')

 

exec u_test @t

posted on 2016-03-01 21:35  zooz  阅读(1891)  评论(0编辑  收藏  举报