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

-- =============================================
-- Author:		Azimi
-- Create date: 1396/05/05
-- Description:	
-- =============================================
ALTER FUNCTION [dbo].[ForTypeOfCashInFormdata] 
(
	@FormData nvarchar(1000)
)
RETURNS Integer
AS
BEGIN
	DECLARE @Result Integer

	DECLARE @Index as integer
	SET @Index = 1
	while @Index < 9 and Len(@FormData)>1
	begin
		--print @FormData
		set @FormData = Substring(@FormData,CHARINDEX(';',@FormData)+1, 1000)
		set @Index = @Index+1
	end
	
	SELECT @Result=0
	if CHARINDEX(';',@FormData)>1
		SELECT @Result =CAST( LEFT(@FormData,CHARINDEX(';',@FormData)-1) as Integer)

	RETURN @Result

END