Avatar of emi_sastra
emi_sastra

asked on 

Filter using multiple value string parameter with dynamic sql script

Hi All,

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.
Microsoft SQL Server

Avatar of undefined
Last Comment
emi_sastra
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of emi_sastra
emi_sastra

ASKER

Hi Icohan,

In my case what should I do ?

Thank you.
Avatar of emi_sastra
emi_sastra

ASKER

Hi Icohan,

Thank you very much for your help.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo