I have a table with an ID column of the type int and another column containing a FileName and Path of the type varchar.I would like to find all records of that table where the value of the varchar column contains the value of the int column.Here is an example and one of the queries I've tried. Obviously this doesn't work. How can I achieve this? Thanks.
-- Test datadeclare @testtable as table(ID int, DocumentName varchar(100))insert into @testtable(ID, DocumentName)values(101,'a path\a.doc'),(102,'other path\321.doc'),(103,'foo\1.xls'),(104,'c:\bla104.pdf'),(105,'321\105.doc'),(106,'folder\1.doc')-- Queryselect *from @testtablewhere DocumentName like( select '%' + convert(varchar,ID) + '%' from @testtable)-- This query gives an error "Subquery returned more than 1 value...." but shows what I'm trying to do-- I would like a query that returns the rows with ID 104, 105