SQL SERVER stored Procedure Doubt

Posted by Mdjack under Sql Server on 9/30/2011 | Points: 10 | Views : 1274 | Status : [Member] | Replies : 7
Hi,

if (ISNULL(@TestResultId,0) > 0 )
the above condition in SQL return only the Zero ?

N. MOHAMED ZACKKARIAH


Responses

Posted by: Blessyjees on: 9/30/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Is (@TestResultId a parameter. Are you set a value for this. the above statement is correct, so make sure the value of (@TestResultId is not null.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayeshl on: 9/30/2011 [Member] Starter | Points: 25

Up
0
Down
hi dear,
i tried your question in mssql server 2005

Declare @TestResultID int

set @TestResultId = null
if (ISNULL(@TestResultId,0) > 0 )
print @TestResultId
else
print '0'

and based on input data it will return's value
like if @TestResultID = null
so it will print 0
or in other case it will print value of that variable

Jayesh L
http://sqlassistant.blogspot.com

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 9/30/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
then @TestResultId is null

Thank you for posting at Dotnetfunda
[Administrator]

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayeshl on: 10/3/2011 [Member] Starter | Points: 25

Up
0
Down
ya you are right but for just of testing purpose it set value to NULL

just comment it and execute your code

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 11/24/2011 [Member] Starter | Points: 25

Up
0
Down
yes @TestResultId is Nll value return


Thanks

Sriram.R

sriram

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajeev.Shukla on: 11/25/2011 [Member] Starter | Points: 25

Up
0
Down
ISNULL(@test,0):
It will first check the parameter value @test whether it is NULL.
If it is NULL, it will assign it as 0.
If it is not NULL, it gives the actual value of the @test parameter.

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayeshl on: 11/25/2011 [Member] Starter | Points: 25

Up
0
Down
ya thanks for update.

Jayesh L
http://sqlassistant.blogspot.com

Mdjack, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response