IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[F_LIMPA_ZERO_ESQUERDA]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
	DROP FUNCTION [dbo].[F_LIMPA_ZERO_ESQUERDA]
GO 

CREATE FUNCTION [dbo].[F_LIMPA_ZERO_ESQUERDA] (@NUMERO AS VARCHAR(MAX)) 
	RETURNS VARCHAR(MAX) AS 
	--select dbo.F_LIMPA_ZERO_ESQUERDA('0000000000001326549')
BEGIN

    /* Autor: Ramam Freitas */ 
	WHILE LEFT(@NUMERO,1) ='0'
		BEGIN		
			SET @NUMERO= RIGHT(@NUMERO, LEN(@NUMERO)-1) 
		END 
	
	RETURN @NUMERO END;
