Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

ricerca sql dalla stringa csv

Puoi usare in questo modo in Stored Procedure,

declare @searchtext varchar(1000)

set searchtext ='bob,harry,charley'

declare @filter varchar(2000)

set @filter = '(name LIKE ''%' + replace('bob,harry,charley',',','%'' OR name LIKE ''%') + '%'')'

exec
('
    select *
    from mytab
    where ' + @filter + '
'
)