如何将空值传递给存储过程 [英] How to pass null value to Stored procedure
问题描述
我想将 null
值传递给我在控制器中调用的存储过程。我将其作为 null
传递,但没有获得正确的记录。该怎么办?
// 我的代码
// / span>
修改程序Proc
(@flag bit = Null)
As Begin
if @flag null
// 我的选择语句
结束
//
var data = _entites.GetData( null ) // 在控制器中调用SP
想要传递 null
某些条件
是不是很好?
看起来应该是这样的:
DECLARE @ flag BIT = NULL
IF ( @ flag IS NULL )
PRINT ' 标记为空!'
如果在之后有超过1行,如果
语句,你必须穿这在 BEGIN .. END
声明中。
IF ( @ flag IS NULL )
BEGIN
PRINT ' Flag null!'
PRINT '请停止传递 null 值!'
END
请参阅: IF ... ELSE(Transact-SQL) [ ^ ]
注意:请阅读< a href =http://www.codeproject.com/script/Membership/View.aspx?mid=11414469> F-ES Sitecore [ ^ ]对问题发表评论。
I want to pass null
value to Stored procedure from where i am calling in controller. I am passing it as null
but not getting correct records. how to do it?
// my code
//in stored procedure that parameter declred as null
Alter Procedure Proc
(@flag bit= Null)
As Begin
if @flag is null
//my select statement
end
//in controller
var data=_entites.GetData(null)//calling SP in controller
want to pass null
for some conditions
is it wirte?
On the first look - if statement in sp is incorrect.
It should look like:
DECLARE @flag BIT = NULL IF (@flag IS NULL) PRINT 'Flag is null!'
In case when there is more than 1 line afterif
statement, you have to "wear" this inBEGIN .. END
statement.
IF (@flag IS NULL) BEGIN PRINT 'Flag is null!' PRINT 'Please stop passing null values!' END
See: IF...ELSE (Transact-SQL)[^]
Note: please, read F-ES Sitecore[^] comment to the question.
这篇关于如何将空值传递给存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!