Default SP value Compare

Posted by Mahe under Sql Server on 9/12/2012 | Points: 10 | Views : 1172 | Status : [Member] | Replies : 1
Hi,

ALTER PROCEDURE XYZ
(@A INT = NULL)
AS
BEGIN
SET NOCOUNT ON;

SELECT A,B
FROM ABC
WHERE A =@A
END

For the above SP,
by default i want null values, if i specify any value it has to compare its value




Responses

Posted by: Pandians on: 9/12/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Check It Out!
ALTER PROCEDURE XYZ 

(@A INT = NULL)
AS
BEGIN
SET NOCOUNT ON;
SELECT A,B FROM ABC WHERE (A =@A Or (@A Is Null And A Is Null))
END
Go


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

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

Login to post response