December 6, 2006 at 4:16 pm
Hi All,
I have been trying to work out what is wrong with my stored procedure for several hours now. I am wondering if anyone can tell me why the variable @varFranchise never equals NULL even though I pass a null value when executing it in SQL 2005. I always get the same output '@varFranchise didnt equal null' in the messages pane so I know that the variable never evaluates to NULL.
ALTER
PROCEDURE [dbo].[web_getCustomisedDetails]
(
@varProductCode
char(25),
@varCompany
char(10),
@varFranchise
int = NULL
)
AS
If
@varFranchise = NULL
begin
Select *
From tblCustomisedDetails
Where LTrim(RTrim(fldProductCode)) = LTrim(RTrim(@varProductCode)) And LTrim(RTrim(fldCompany)) = LTrim(RTrim(@varCompany))
Order By fldProductCode Desc;
Print '@varFranchise = null'
end
Else
begin
Select *
From tblCustomisedDetails
Where LTrim(RTrim(fldProductCode)) = LTrim(RTrim(@varProductCode)) And LTrim(RTrim(fldCompany)) = LTrim(RTrim(@varCompany)) And fldFranchise = @varFranchise
Order By fldProductCode Desc;
Print '@varFranchise didnt equal null'
end
@varFranchise
Cheers
AB
December 6, 2006 at 4:20 pm
Sorry, solved my own problem. I should have used 'If @varFranchise IS NULL' Instead of 'If @varFranchise = NULL'.
Cheers
ab
December 6, 2006 at 4:23 pm
ALTER PROCEDURE [dbo].[web_getCustomisedDetails]
(
@varProductCode
char(25),
@varCompany
char(10),
@varFranchise
int = NULL
)
AS
If
@varFranchise IS NULL
begin
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply