调用存储过程,传递NULL值,处理布尔值 [英] Calling stored procedures, passing NULL values, dealing with boolean values

查看:36
本文介绍了调用存储过程,传递NULL值,处理布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调用存储过程时,我将值串联在一起,我的问题是如何调用存储过程,但在其中一个参数中发送"NULL"值?

When calling a stored procedure I am concatenating values together, my question is how do you call a stored procedure but send a 'NULL' value in one of the params?

让我们说AID = null,但是如果我将其传递给查询,则会收到错误消息?!

Lets say that AID = null, but if I pass that to my query I get an error?!

QueryConn.Execute("Search_Res " & Count & "," & AccessList("InvoiceLevel") & "," & AID)

好的,所以我的下一个问题将是如何传递布尔变量?

Ok, so my next question is going to be how do I pass in a boolean variable?

在我的存储过程中,var @SearchChildren是true还是false,但是我应该如何定义它?还是应该使用int来简化事情,只使用0或1?

Within my stored procedure the var @SearchChildren is either true or false, but how do I define this or should I go with an int and make things simple for myself and just use 0 or 1?

MS SQL Server 2005.

MS SQL Server 2005.

推荐答案

Search_Res 存储过程的参数更改为可选.@parameter = NULL.传递NULL值后,该参数将被忽略.

Change the parameter of the Search_Res stored procedure to be optional. @parameter = NULL. When NULL value is passed the parameter is ignored.

CREATE PROCEDURE dbo.foo 
    @param INT = NULL 
AS 
BEGIN ...

这篇关于调用存储过程,传递NULL值,处理布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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