BUG: Stored Procedures Cannot Process NULL Parameters from VBLast reviewed: November 24, 1997Article ID: Q177187 |
The information in this article applies to:
SYMPTOMSA SQL stored procedure produces unexpected results if a NULL parameter is passed from a Visual Basic application using RDO. This behavior also occurs if the SQL stored procedure declares an optional parameter whose default value is NULL and no parameters are passed.
RESOLUTIONThe workaround is to modify the SELECT statement in the stored procedure. If a stored procedure is declared as:
CREATE PROC Test_SP @Param VARCHAR (20) = NULL AS SELECT * FROM Test_Table WHERE Field = @Param GOreplace it with:
CREATE PROC Test_SP @Param VARCHAR (20) = NULL AS IF @Param = NULL SELECT * FROM Test_Table WHERE Field = NULL ELSE SELECT * FROM Test_Table WHERE Field = @Param GOThe following can also be used:
CREATE PROC Test_SP @Param VARCHAR (20) = NULL AS SELECT * FROM Test_Table WHERE (Field = NULL and @Param = NULL) OR (Field = @Param) GO STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional query words: sqlserver
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |