/****** Object:  UserDefinedFunction [dbo].[GetFormdataItem]    Script Date: 30/06/2021 09:59:30 ق.ظ ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		Azimi
-- Create date: 1396/05/05
-- Description:	
-- =============================================
ALTER FUNCTION [dbo].[GetFormdataItem] 
(
	@FormData nvarchar(1000),
	@ItemNum integer
)
RETURNS nvarchar(1000)
AS
BEGIN
	DECLARE @Index as integer
	SET @Index = 1
	while @Index < @ItemNum
	begin
		--print @FormData
		if CHARINDEX(';',@FormData) > 0
		begin
			set @FormData = Substring(@FormData,CHARINDEX(';',@FormData)+1, 1000)
			set @Index = @Index+1
		end
		else
			break
	end
	--Cash1;2,4,7,0;1,1,0,0;02/07/2015;100000/222;تتس
	-- Return the result of the function
	if @Index < @ItemNum
		set @FormData=null 
	else
		if CHARINDEX(';',@FormData)>0
			set @FormData = REPLACE(LEFT(@FormData,CHARINDEX(';',@FormData)-1),'/','.')

	RETURN @FormData
END











