mssql how to use exists in select list Edit

Murugan Andezuthu Dharmaratnam | 18 October 2020 | 100

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

Solution

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