IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[FN_OzelKarekterVarMi]') AND xtype in (N'FN', N'IF', N'TF'))
DROP FUNCTION [dbo].[FN_OzelKarekterVarMi]
go

CREATE FUNCTION [dbo].[FN_OzelKarekterVarMi](@STR NVARCHAR(100))  
RETURNS BIT
AS
 
BEGIN
	--DECLARE @STR NVARCHAR(20)='SERD-AR'
	DECLARE @UZUNLUK INT
	DECLARE @SAYAC INT
	DECLARE @ARA NVARCHAR(20)


	SET @UZUNLUK = 0
	WHILE @UZUNLUK<=LEN(@STR)
	BEGIN
		SET @ARA=SUBSTRING(@STR,LEN(@STR)-@UZUNLUK,1)
		
		IF NOT ((ASCII(@ARA)>=48 AND ASCII(@ARA)<57) OR (ASCII(@ARA)>=65 AND ASCII(@ARA)<97) OR (ASCII(@ARA)>=90 AND ASCII(@ARA)<122) OR (ASCII(@ARA)=32) )  /*32=BOŞLUK=SPACE ONUDA KONTROL ETMESİN*/
		BEGIN			
			 RETURN 1
			 BREAK
        END

		SET @UZUNLUK=@UZUNLUK+1
		
	END
	RETURN 0
END


--SELECT DBO.[FN_OzelKarekterVarMi]('s	ERDAR')

--SELECT ASCII(' ') BOSLUK,ASCII('	') TAB,ASCII(' ') ALT255
