The question is fairly clear. I wanna check if for example a number x is contained in another number y. And I wanna do it in SQL (also in LINQ if possible). Additionally those integer values(y values) are Ids from a table. So when LINQ is concerned, I am not looking for some general solution like:
int y=123,x=32; bool isContainedInY = y.ToString().Contains(x.ToString());
Examples:
x = 5, y = 1256 => true x = 384, y = 38412 => true x = 1, y = 5236 => false
Answers can be based on a table like the following:
+------+-------+ | Id | Name | +------+-------+ | 52 | Lola | | 65 | Dolly | | 88 | Wolly | | 102 | Sorry | +------+-------+
Advertisement
Answer
You can cast them to varchar first
SELECT CHARINDEX(STR(x), STR(y)) > 0