mssql how to use exists in select list edit button Edit

Murugan Andezuthu Dharmaratnam | calendar 18 October 2020 | 1530

How to use EXISTS in a select statement where you want to return a boolean column


select  Item.Id as ItemId, Item.Name, SKU, Item.Name as ImageUrl, 
CAST(CASE WHEN EXISTS(select * from ItemSimilarMapping where ItemId=@ItemId and ItemSimilarMapping.SimilarItemId = Item.Id) THEN 1 ELSE 0 end as bit) As IsSimilar
from Item