DECLARE @Org1 NVARCHAR(100) = ('1')
select * from LD0VYC20 where ORGENHNR like @Org1+ '%'
The above code works fine when it has just have one value in the variable, but when it has multiple values as in below:
DECLARE @Org NVARCHAR(100) = ('111,11')
How can we apply like clause to get all the records.
I tried below approach:
DECLARE @Org1 NVARCHAR(100) = ('1,111')
select * from LD0VYC20 where ORGENHNR like (select value from STRING_SPLIT(@Org1,','))+ '%'
But it gives error as : Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.