sql 用户自定义表类型和使用

--表类型
USE
[emmis] GO CREATE TYPE [dbo].[WeightVolumeType] AS TABLE( [ilong] [int] NULL, [iwidth] [int] NULL, [iheight] [int] NULL, [actweight] [decimal](18, 3) NULL, [ivolume] [decimal](18, 3) NULL ) GO

存储过程的创建值

CREATE PROCEDURE 存储过程名称
    @volumetable WeightVolumeType READONLY  --自定义表变量
   ,@icid INT
   ,@cemskind VARCHAR(30)
--使用方式和表一样
select * FROM @volumetabl

c#的调用,dt的值类型是 DataTable

string StorePro = "op_weight_addcharges";
            SqlParameter[] parameters =
            {
                new SqlParameter("@volumetable", SqlDbType.Structured ){Value=dt},
                new SqlParameter("@icid", SqlDbType.Int ){Value=icid},
                new SqlParameter("@cemskind", SqlDbType.VarChar,30){Value=cemskind},
            };
原文地址:https://www.cnblogs.com/shuaimeng/p/13053893.html