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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Extract last word from a char field

Author  Topic 

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 2005-03-24 : 15:23:53
charfield = "This is word four". What function can I use to return the last word of a char column?

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 2005-03-24 : 15:34:12
Never mind - found Reverse function.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-03-25 : 08:27:10
declare @var varchar(100)
set @var='This is word four'
select reverse(left(reverse(@var),charindex(' ',reverse(@var))-1))


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -