title: How to use Pass comma separated string in dynamic query in SQL
body: <p>I have a function which will return integer values from comma delimited string , It takes two parameters (@string nvarchar(4000), @delimiter char(1)). So the problem is if I am using this function inside a dynamic query I am getting error , here is query </p>
  
  <pre><code>declare @ProductIDs varchar(11)
  declare @SQL varchar(max)
  
  set @ProductIDs='1,2,3,4'
  declare @query varchar(max)
  --set @query= @ProductIDs +','+@Delimiter
  
  SELECT @SQL = 'SELECT val FROM dbo.[fnDelimitedStringToTable]('+ @ProductIDs +' , '','')'
  
  Exec(@SQL)
  </code></pre>
  
  <p>I am getting error Procedure or function dbo.fnDelimitedStringToTable has too many arguments specified. </p>