Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
misterraj
Yak Posting Veteran
94 Posts |
Posted - 2014-12-23 : 07:36:15
|
I have a sentence/word and for each word in the sentence if a word finishes with 's' i want to remove the letter 's'.Note if and only 's' letter is the last letter in a word.thanksvenkat. |
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2014-12-23 : 08:43:00
|
The kind of thing:declare @String varchar(max)set @String = 'tests and more tests'IF (RIGHT(@String, 1) = 's') set @String = LEFT(@String, LEN(@String) - 1) Select @stringWe are the creators of our own reality! |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2014-12-23 : 08:45:22
|
SELECT REPLACE(sentence,'s ', ' ') FROM myTableFor S followed by punctuation:SELECT REPLACE(REPLACE(REPLACE(sentence,'s.','.'),'s,',','),'s!','!') FROM myTableFor sentence ending in S:SELECT CASE WHEN sentence LIKE '%s' THEN STUFF(sentence,LEN(sentence)-1,1,'') ELSE sentence END FROM myTable |
|
|
misterraj
Yak Posting Veteran
94 Posts |
Posted - 2014-12-23 : 09:31:18
|
thanks. great!!! |
|
|
|
|
|
|
|