开发者

sql select string coming before space dash space

select string coming before space dash space

say table 1

id |开发者_Python百科 name 1 | Poo - SR 2 | S-h-r - SR 3 | SDR - mj 4 | srk - kl

i want it like

id | name 1 | Poo 2 | S-h-r 3 | SDR 4 | srk


use REPLACE function in SQL? example :SELECT REPLACE('abcdefghicde','cde','xxx');


You can use

select left(@column, charindex(' - ',@column) - 1 )+' '+right(right(@column, charindex(' - ',@column) + 1),charindex(' ',right(@column, charindex(' - ',@column) + 0))+1)

Replace @column with your table column name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜