The following describes how to create User defined table type and also how to use them in a SP
CREATE PROCEDURE CreatingUserDefiendTableType
AS
BEGIN
SET NOCOUNT ON;
CREATE TYPE TableType1 AS TABLE
( Name VARCHAR(50)
, Code INT );
CREATE TYPE TableType2 AS TABLE
( Name VARCHAR(50)
, ID INT );
END
GO
Call the SP
exec CreatingUserDefiendTableType
Create another SP for using them
Create PROCEDURE [dbo].UsingUserDefiendTableType
AS
BEGIN
SET NOCOUNT ON;
declare @type1 TableType1
declare @type2 TableType2
insert into @type1 values ('TestTableType1' , 12);
Select * from @type1
insert into @type2 values ('TestTableType2' , 13);
Select * from @type2
END
Call the Second SP
exec UsingUserDefiendTableType