title: sql server passing string for in parameters
body: <p>i have a scalar valued function like this</p>
  
  <pre><code>CREATE FUNCTION getTotalWorkingSeconds(@machineList varchar(255))
  RETURNS int
  AS
  BEGIN
    declare @res int
    Select @res =  Sum(DURATION) From PROCESSDATA where MACHINEID in (@machineList)
    return @res
  END
  </code></pre>
  
  <p>i tried to use it like these</p>
  
  <pre><code>SELECT dbo.getTotalWorkingSeconds('3,2')
  
  result; Conversion failed when converting the varchar value '3,2' to data type int.
  </code></pre>
  
  <p>-- </p>
  
  <pre><code>SELECT dbo.getTotalWorkingSeconds(''''+'3,2'+'''')
  
  result; Conversion failed when converting the varchar value ''3,2'' to data type int.
  </code></pre>
  
  <p>how i can pass id list to this function?</p>
  
  <p>Edit: i can alter the function.</p>