表中的值可选参数 [英] Table Value optional parameter

查看:99
本文介绍了表中的值可选参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建一个表值参数作为可选参数的过程。

Is it possible to create a procedure with a table value parameter as an optional parameter.

我尝试以下code:

CREATE PROCEDURE SP
@Table testteype = null READONLY
AS 
....

但我得到这个错误:

But I get this error:

Operand type clash: void type is incompatible with test type 

PS:我使用SQL Server用C#.NET

ps: I use sql server with C#.Net

推荐答案

表值参数总是有一个空表的隐含价值。所以,你可以实际调用该程序不带任何参数,它会执行,但该表是空的。

Table-Valued parameters always have an implicit value of an empty table. So you can actually call that procedure without any parameters and it would execute but the table would be empty.

所以它并没有真正意义的标签表值参数有一个默认值。删除=空,检查表内容,你应该是好去。

So it doesn't really make sense to label a table-value parameter with a default value. Remove the "=null", check the table contents, and you should be good to go.

这篇关于表中的值可选参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆