TSQL e alfabeto carbonaro
09-01-2024
Piccola funzione di conversione in alfabeto carbonaro e viceversa
TSQL
09-01-2024
Piccola funzione di conversione in alfabeto carbonaro e viceversa
CREATE FUNCTION dbo.Carbonaro (@in VARCHAR(255))
RETURNS VARCHAR(255)
AS
BEGIN
DECLARE @RET VARCHAR(255) = LOWER(@in)
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'a', 'O')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'b', 'P')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'c', 'G')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'd', 'T')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'e', 'I')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'f', 'V')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'g', 'C')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'h', 'H')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'i', 'E')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'j', 'J')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'k', 'K')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'l', 'R')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'm', 'N')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'n', 'M')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'o', 'A')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'p', 'B')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'q', 'Q')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'r', 'L')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 's', 'Z')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 't', 'D')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'u', 'U')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'v', 'F')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'w', 'W')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'x', 'X')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'y', 'Y')
SET @RET = REPLACE(@RET COLLATE Latin1_General_CS_AS, 'z', 'S')
RETURN @RET;
END
GO
-- UTILIZZO
SELECT dbo.Carbonaro([Testo]) FROM TabellaCifrata