开发者

sql select string coming before space dash space

开发者 https://www.devze.com 2023-03-22 08:05 出处:网络
select string coming before space dash space say table 1 id |开发者_Python百科 name 1 | Poo - SR 2 | S-h-r - SR

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

精彩评论

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

关注公众号