[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

TSQl - strip last word of string if.

I'm trying to parse some string input together.

How can I check if the very last word of a phrase is "and" and replace it with "."
I can't use replace() because "and" elsewhere in the phrase is appropriate.

thanks
0
PMH4514
Asked:
PMH4514
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
select case when right(urColumn,4 ) = ' and' then Left(urColumn, len(urColumn)-4 )+'.' else urColumn end
from yourTable
0
 
PMH4514Author Commented:
ahh, nice and simple. thank you
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now