All Time Show Null value
Please help me what is the wrong in my code

declare @mxdbvlu  int
 declare @dbvlunm int
  set @mxdbvlu= (select max(Database_name) from TBL_FY_SELECT_1)
 if @mxdbvlu = null 
 set @dbvlunm=1000
 else 
 set @dbvlunm=sum(@mxdbvlu+1)
  select @dbvlunm,@mxdbvlu

Recommended Answers

All 3 Replies

Hopefully in line 4. if @mxdbvlu == null instead of if @mxdbvlu = null

I think there should be Column_name insted of Database_name
and there should be "if @mxdbvlu is null" insted of "if @mxdbvlu = null"
I tried after these changes and its working

A null is never equal to something, a value can't equal null, as a null just doesn't exist. That's why you have to use the options suggested above. The second suggestion "if @mxdbvlu is null" is the standard way to test for not existing, as it says if a value doesn't exist...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.