0
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.

  • 2
    Don't tag spam. Just tag the RDBMS you are *really* using. I have removed all the conflicting tags. [Edit] your question to tag correctly. – Larnu Oct 21 '21 at 10:08

0 Answers0