i have a scalar valued function like this
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
i tried to use it like these
SELECT dbo.getTotalWorkingSeconds('3,2')
result; Conversion failed when converting the varchar value '3,2' to data type int.
--
SELECT dbo.getTotalWorkingSeconds(''''+'3,2'+'''')
result; Conversion failed when converting the varchar value ''3,2'' to data type int.
how i can pass id list to this function?
Edit: i can alter the function.
3,2string to be treated as two comma-separated integers, you'd have to build/execute the query statement dynamically.Split Functioninside your function to use these comma separated values.