1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
USE [x]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE FUNCTION [dbo].[ConvertString2Greeklish]
(
@inp VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @temp VARCHAR(8000), @i INT
SET @inp = LOWER(@inp)
SET @Temp=''
SET @i = 1
while @i <= LEN(@inp)
BEGIN
IF SUBSTRING(@inp, @i, 1)= 'α' SET @temp = @temp + 'a'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ά' SET @temp = @temp + 'a'
ELSE IF SUBSTRING(@inp, @i, 1)= 'β' SET @temp = @temp + 'b'
ELSE IF SUBSTRING(@inp, @i, 1)= 'γ' SET @temp = @temp + 'g'
ELSE IF SUBSTRING(@inp, @i, 1)= 'δ' SET @temp = @temp + 'd'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ε' SET @temp = @temp + 'e'
ELSE IF SUBSTRING(@inp, @i, 1)= 'έ' SET @temp = @temp + 'e'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ζ' SET @temp = @temp + 'z'
ELSE IF SUBSTRING(@inp, @i, 1)= 'η' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ι' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ή' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ί' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'υ' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ύ' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ϊ' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ΐ' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ϋ' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ΰ' SET @temp = @temp + 'i'
ELSE IF SUBSTRING(@inp, @i, 1)= 'θ' SET @temp = @temp + 'u'
ELSE IF SUBSTRING(@inp, @i, 1)= 'κ' SET @temp = @temp + 'k'
ELSE IF SUBSTRING(@inp, @i, 1)= 'λ' SET @temp = @temp + 'l'
ELSE IF SUBSTRING(@inp, @i, 1)= 'μ' SET @temp = @temp + 'm'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ν' SET @temp = @temp + 'n'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ξ' SET @temp = @temp + 'j'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ο' SET @temp = @temp + 'o'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ό' SET @temp = @temp + 'o'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ω' SET @temp = @temp + 'o'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ώ' SET @temp = @temp + 'o'
ELSE IF SUBSTRING(@inp, @i, 1)= 'π' SET @temp = @temp + 'p'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ρ' SET @temp = @temp + 'r'
ELSE IF SUBSTRING(@inp, @i, 1)= 'σ' SET @temp = @temp + 's'
ELSE IF SUBSTRING(@inp, @i, 1)= 'τ' SET @temp = @temp + 't'
ELSE IF SUBSTRING(@inp, @i, 1)= 'φ' SET @temp = @temp + 'f'
ELSE IF SUBSTRING(@inp, @i, 1)= 'χ' SET @temp = @temp + 'x'
ELSE IF SUBSTRING(@inp, @i, 1)= 'ψ' SET @temp = @temp + 'c'
ELSE SET @temp = @temp + SUBSTRING(@inp, @i, 1)
SET @i = @i + 1
end
-- Noise removal
SET @temp = REPLACE(@temp, ' tis ', ' ')
SET @temp = REPLACE(@temp, ' toi ', ' ')
SET @temp = REPLACE(@temp, ' ton ', ' ')
SET @temp = REPLACE(@temp, ' kai ', ' ')
SET @temp = REPLACE(@temp, ' ta ', ' ')
SET @temp = REPLACE(@temp, ' ton ', ' ')
SET @temp = REPLACE(@temp, ' ayta ', ' ')
SET @temp = REPLACE(@temp, ' oi ', ' ')
SET @temp = REPLACE(@temp, ' ston ', ' ')
SET @temp = REPLACE(@temp, ' stin ', ' ')
SET @temp = REPLACE(@temp, ' sti ', ' ')
SET @temp = REPLACE(@temp, ' sto ', ' ')
SET @temp = REPLACE(@temp, ' sta ', ' ')
SET @temp = REPLACE(@temp, ' i ', ' ')
SET @temp = REPLACE(@temp, ' ek ', ' ')
RETURN @temp
END
origin - http://www.pipiscrew.com/?p=3632 sql-convertstring2greeklish