回答編集履歴
1
追記
test
CHANGED
@@ -7,3 +7,27 @@
|
|
7
7
|
SELECT SUBSTRING(mail,1,CHARINDEX(mail,'@')-1)
|
8
8
|
|
9
9
|
```
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
NULLと@を含まない場合の対策版
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```SQL
|
18
|
+
|
19
|
+
SELECT
|
20
|
+
|
21
|
+
CASE mail
|
22
|
+
|
23
|
+
WHEN NULL THEN
|
24
|
+
|
25
|
+
NULL
|
26
|
+
|
27
|
+
ELSE
|
28
|
+
|
29
|
+
SUBSTRING(mail,1,CASE CHARINDEX('@',mail) WHEN 0 THEN LEN(mail) ELSE CHARINDEX('@',mail)-1 END)
|
30
|
+
|
31
|
+
END;
|
32
|
+
|
33
|
+
```
|