ppp80的专栏

追求-恬静的生活

一个SQL tvp+.net的例子

1声明表值参数

declare@TaxDTOSettvp_CBO_ARDrawBill_TaxReadOnly

2批量插入表

set@Sql=

       'insert into '+@TableName

           +'selectDrawBillView_ID,'

                  +'Tax,Tax_Code,Tax_Name,'

                  +'TaxRate,TaxMoney_OCMoney,CurrentTaxMoney,'

                  +'Symbol,MoneyRound_Precision,MoneyRound_RoundType,MoneyRound_RoundValue'

              +' from  @TaxDTOSet'

    set@Param='@TaxDTOSettvp_CBO_ARDrawBill_Tax ReadOnly'

    execsp_executesql@Sql,@Param,@TaxDTOSet=@TaxDTOSet

3.net调用

using (IDbCommand cmd =conn.CreateCommand())

                    {

                        cmd.CommandText = "AR_UpdateDrawBillData_tvp";

                        cmd.CommandType =CommandType.StoredProcedure;

                        cmd.CommandTimeout = 0;

 

                        SqlParameter tableName= new SqlParameter("TableName",SqlDbType.NVarChar);

                        tableName.Value =args.TempTable;

                       cmd.Parameters.Add(tableName);

            cmd.Parameters.Add(DataParamFactory.CreateTableParam("TaxDTOSet", "tvp_CBO_ARDrawBill_Tax", taxTbl));

 

                        cmd.ExecuteNonQuery();

                    }

阅读更多
文章标签: tvp net
个人分类: 数据库
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭