表中有一字段的值存在着纯数字和中文的字符串,如
123
我爱你123、1223
我爱你123我爱你1234我爱你123
我爱你123我爱你
123我爱你
现在需要把这个字段中的前面和后面是中文的去掉,中间有中文或者符号的不管,更新后字段值为
123
123、1223
123我爱你1234我爱你123
123
123
请问SQL更新语句怎么写?
------解决方案--------------------
- SQL code
create table tb(col nvarchar(30))insert into tb select '123'insert into tb select '我爱你123、1223'insert into tb select '我爱你123我爱你1234我爱你123'insert into tb select '我爱你123我爱你'insert into tb select '123我爱你'goselect substring(col,PATINDEX('%[^吖-做]%',col),len(col)-Patindex('%[^吖-做]%',REVERSE(col))-PATINDEX('%[^吖-做]%',col)+2) from tb/*------------------------------123123、1223123我爱你1234我爱你123123123(5 行受影响)*/godrop table tb