USE [P21]
GO

/****** Object:  UserDefinedFunction [dbo].[nutech_multi_valued_user_input_parameter]    Script Date: 9/23/2024 6:35:11 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- ===================================================
-- Author:		Fred Rappuhn, NuTech Services, LLC
-- Create date: 08/17/2021
-- Description:	
-- ===================================================
CREATE FUNCTION [dbo].[nutech_multi_valued_user_input_parameter] (
	@INPUTSTRING as varchar(255))
RETURNS @multi_valued_user_input TABLE 
(	
string_parameter			VARCHAR(255) NULL
,integer_parameter			INTEGER NULL
)
AS
BEGIN

  DECLARE @str_param VARCHAR(255)
  DECLARE @int_param integer

  SET @INPUTSTRING=@INPUTSTRING+','

  WHILE CHARINDEX(',',@INPUTSTRING)<>0
  BEGIN
    SELECT @str_param=LEFT(@INPUTSTRING, CHARINDEX(',',@INPUTSTRING)-1)
	SELECT @int_param=CAST( @str_param as Integer )
    INSERT INTO @multi_valued_user_input VALUES(@str_param, @int_param)
    SET @INPUTSTRING=(SELECT RIGHT(@INPUTSTRING,LEN(@INPUTSTRING)-CHARINDEX(',',@INPUTSTRING)))
  END

return

END
GO


