CREATE FUNCTION dbo.aif_removecolons
(
@strSource nvarchar(2048)
)
RETURNS nvarchar(2048)
AS
BEGIN
DECLARE @intPos int
DECLARE @strBeg nvarchar(2048)
DECLARE @strEnd nvarchar(2048)
IF (@strSource = '')
OR (@strSource IS NULL)
RETURN ''
SET @strSource = LTRIM(@strSource)
WHILE @strSource LIKE '%[:]%'
BEGIN
SET @intPos = CHARINDEX(':', @strSource)
SET @strBeg = LEFT(@strSource, @intPos - 1)
SET @strEnd = SUBSTRING(@strSource, @intPos + 1, 2048)
IF (RIGHT(@strBeg, 1) = ' ')
AND (LEFT(@strEnd, 1) = ' ')
SET @strBeg = RTRIM(@strBeg)
SET @strSource = @strBeg + @strEnd
END
IF (LEN(@strSource) != 12)
SET @strSource = ''
RETURN @strSource
END
GO
GRANT EXECUTE ON [dbo].[aif_removecolons] TO [aiadmin]
GO