emi_sastra
asked on
Filter using multiple value string parameter with dynamic sql script
Hi All,
I try below code.
What I want to achieve is show data from TMBARANG that has data 'CREPE' and CREPE 1018 1380 like below code :
SELECT BARANGCODE FROM TMBARANG
WHERE BARANGCODE IN ('CREPE', 'CREPE 1018 1380')
How could I do it ?
Thank you.
I try below code.
declare @Barangcode VARCHAR(100) = '''CREPE'', ''CREPE 1018 1380'''
DECLARE @SQL VARCHAR(MAX) = '
SELECT BARANGCODE FROM TMBARANG
WHERE BARANGCODE IN
(
SELECT ''' + REPLACE(@BarangCode, '''', '') + '''
)
PRINT @SQL
EXECUTE (@SQL)
What I want to achieve is show data from TMBARANG that has data 'CREPE' and CREPE 1018 1380 like below code :
SELECT BARANGCODE FROM TMBARANG
WHERE BARANGCODE IN ('CREPE', 'CREPE 1018 1380')
How could I do it ?
Thank you.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi Icohan,
Thank you very much for your help.
Thank you very much for your help.
ASKER
In my case what should I do ?
Thank you.