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
精彩评论