I want a select statement which will find me if there is any row with column expired value = 1.
This is what I am trying with no luck,
Declare @FruitID INT;
SET @FruitID = '2876';
 SELECT 
    dbo.IsFruitExpired(@FruitID, Fruits.CrateID) AS FruitExpired
 FROM 
    Fruits  WHERE   Fruits.ID = @FruitID 
Result
FruitExpired
0
0
1
0
So I want to return 1 if there is any row with value = 1 otherwise return 0, I am going to add this select statement in a function.
 
     
    