
/****** Object:  UserDefinedFunction [dbo].[ForTypeOfPAYAInFormdata]    Script Date: 21/08/2021 05:53:37 ب.ظ ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		Azimi
-- Create date: 1396/05/05
-- Description:	
-- =============================================
CREATE FUNCTION [dbo].[ForTypeOfPAYAInFormdata] 
(
	@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