我有表格test( ID Numeric(11,0), report varchar(255) )
和数据如下
1 ,Age,,,,,,family_status,,,,,,
2 ,,,,,,,,retaliation,hostile environment,,,,
3 ,,,,,,,,,,,,,
4 ,,,,,,,,retaliation,,,,,
5 ,,,,,,,,,hostile environment,,,,
6 ,Age,,,,,,,,,,,,
7 ,,,,national_origin,,,,,,,,,
8 Sex,,,,,,,,,,,,,
9 ,,,,national_origin,,disability,,retaliation,,,,,
10 Sex,,,,,,,,retaliation,,,,,
11 ,,,,,,,,
我想通过替换或使用任何其他数据来删除额外的逗号来更新此表,以便数据看起来
1 Age,family_status
2 retaliation,hostile environment
3
4 retaliation
5 hostile environment
6 Age
7 national_origin,
8 Sex
9 national_origin,disability,retaliation
10 Sex,retaliation
11
我尝试使用以下语句,但不确定如何循环,以便检查并删除所有逗号
UPDATE table test SET report = replace(report , ',,', ',')