DECLARE @c varchar(100) SET @c = 'This is and example #COIN-XXXX data only'
所以基本上,我想要硬币之后的所有东西-到空间,即(仅x)。我该怎么解决?
pgky5nke1#
另一种方法是:
DECLARE @word varchar(max) = '#COIN-XXXX This is and example data only' DECLARE @c varchar(100) = '#COIN1-' DECLARE @CharIndex int = (select CHARINDEX(@c, @word)) if @CharIndex = 0 select 'No matching word' DECLARE @firstSpaceAfter_index int = (select CHARINDEX(' ', @word, @CharIndex)) if @firstSpaceAfter_index = 0 set @firstSpaceAfter_index = len(@word) + 1 SELECT REPLACE(SUBSTRING(@WORD, @CharIndex, @firstSpaceAfter_index - @CharIndex),@c, '')
7cwmlq892#
一种方法是:
select left(v.str, charindex(' ', v.str) - 1) from (select @c as str) x cross apply (values (stuff(x.str, 1, charindex('#COIN', x.str) + 5, ''))) v(str);
这是一把小提琴。
2条答案
按热度按时间pgky5nke1#
另一种方法是:
7cwmlq892#
一种方法是:
这是一把小提琴。