I am trying to create a stored procedure which will check for a list names in a table and there corresponding (boolean/bit) values, even if one of record has value as true, stored procedure should return True, if not then return false.
Here's the table,
Table Name - FruitCrate
Column A (VarChar (Max)) - FruitName
Column B (bit) - Eatable
Now I want a stored procedure whom I can provide a List FruitNames and it checks if any of them is eatable then return true otherwise false.
Not sure how to get started as never sent list as parameter to stored procedure.
Edit
This is what I am trying but getting syntax error,
Create PROCEDURE [dbo].[ProcedureName]
(
@FruitNames varchar(max)
)
AS
Select * From
(SELECT * FROM FruitCrate WHERE FruitName IN (' +@FruitNames+ '))
WHERE FruitCrate.Eatable= 1
Error **
... Incorrect syntax near ')'.... Incorrect syntax near the keyword 'WHERE'.
**