-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSetup.sql
151 lines (117 loc) · 3.38 KB
/
Setup.sql
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* ****************************************************
Script : Setup.sql
Purpose : Installation script for setting up words
Date Created : 10 January 2022
Description : Popular word game called Wordle in T-SQL
for Microsoft SQL Server 2017+
Based on https://powerlanguage.co.uk/wordle/
Author : Tomaz Kastrun (Twitter: @tomaz_tsql)
(Github: github.com\tomaztk)
******************************************************** */
USE Master;
GO
CREATE DATABASE TSQLWordle;
GO
USE TSQLWordle;
GO
DROP TABLE IF EXISTS dbo.Words;
GO
CREATE TABLE dbo.Words
( ID INT IDENTITY(1,1)
, word NVARCHAR(10) NOT NULL
, lang CHAR(3) NOT NULL
);
-- Insert english words
DROP TABLE IF EXISTS dbo.TempWords;
CREATE TABLE dbo.TempWords
(
word NVARCHAR(10)
);
BULK INSERT dbo.TempWords
--FROM '/Users/tomazkastrun/Documents/tomaztk_github/tsqlwordle/languages/english.txt' -- Linux
FROM 'C:\DataTK\git\tsqlwordle\languages\english.txt' -- Windows
WITH (FIRSTROW = 1
,ROWTERMINATOR='\n');
-- (1384 rows affected)
INSERT INTO dbo.Words
SELECT
word
,'EN' as lang
FROM TempWords;
-- (1384 rows affected)
-- Insert Slovenian words
DROP TABLE IF EXISTS dbo.TempWords;
CREATE TABLE dbo.TempWords
(
word NVARCHAR(10)
);
BULK INSERT dbo.TempWords
-- FROM '/Users/tomazkastrun/Documents/tomaztk_github/tsqlwordle/languages/slovenian.txt' -- linux
FROM 'C:\DataTK\git\tsqlwordle\languages\slovenian.txt' -- windows
WITH (FIRSTROW = 1
,ROWTERMINATOR='\n');
-- (12861 rows affected)
INSERT INTO dbo.Words
SELECT
word
,'SI' as lang
FROM TempWords;
-- (12861 rows affected)
-- Insert Italian words
DROP TABLE IF EXISTS dbo.TempWords;
CREATE TABLE dbo.TempWords
(
word NVARCHAR(10)
);
BULK INSERT dbo.TempWords
-- FROM '/Users/tomazkastrun/Documents/tomaztk_github/tsqlwordle/languages/italian.txt' -- linux
FROM 'C:\DataTK\git\tsqlwordle\languages\italian.txt' -- windows
WITH (FIRSTROW = 1
,ROWTERMINATOR='\n');
-- (12861 rows affected)
INSERT INTO dbo.Words
SELECT
word
,'IT' as lang
FROM TempWords;
-- (0 row(s) affected)
-- Insert German words
DROP TABLE IF EXISTS dbo.TempWords;
CREATE TABLE dbo.TempWords
(
word NVARCHAR(10)
);
BULK INSERT dbo.TempWords
-- FROM '/Users/tomazkastrun/Documents/tomaztk_github/tsqlwordle/languages/german.txt' -- linux
FROM 'C:\DataTK\git\tsqlwordle\languages\german.txt' -- windows
WITH (FIRSTROW = 1
,ROWTERMINATOR='\n');
-- (12861 rows affected)
INSERT INTO dbo.Words
SELECT
word
,'DE' as lang
FROM TempWords;
-- (0 row(s) affected)
DROP TABLE IF EXISTS dbo.Keyboard;
GO
CREATE TABLE dbo.Keyboard
(
ID INT IDENTITY(1,1)
,Krow INT NOT NULL
,Kkey NVARCHAR(100) NOT NULL
,lang CHAR(3) NOT NULL
)
INSERT INTO dbo.Keyboard
SELECT 1, 'Q; W; E; R; T; Y; U; I; O; P', 'EN' UNION ALL
SELECT 2, 'A; S; D; F; G; H; J; K; L', 'EN' UNION ALL
SELECT 3, 'Z; X; C; V; B; N; M', 'EN' UNION ALL
SELECT 1, 'Q; W; E; R; T; Z; U; I; O; P; Š; Đ', 'SI' UNION ALL
SELECT 2, 'A; S; D; F; G; H; J; K; L; Č; Ć; Ž', 'SI' UNION ALL
SELECT 3, 'Y; X; C; V; B; N; M', 'SI' UNION ALL
SELECT 1, 'Q; W; E; R; T; Z; U; I; O; P; Ü', 'DE' UNION ALL
SELECT 2, 'A; S; D; F; G; H; J; K; L; Ö; Ä', 'DE' UNION ALL
SELECT 3, 'Y; X; C; V; B; N; M', 'DE'
SELECT 1, 'Q; W; E; R; T; Z; U; I; O; P', 'IT' UNION ALL
SELECT 2, 'A; S; D; F; G; H; J; K; L', 'IT' UNION ALL
SELECT 3, 'Y; X; C; V; B; N; M', 'IT'