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 2005 Forums
 Transact-SQL (2005)
 Get part of text

Author  Topic 

oasis1
Starting Member

35 Posts

Posted - 2012-10-02 : 16:57:25
Aloha I have the folowing value in a column

Q1 (All vers.) How carefully Prov. listened

I need to strip off the Q1 (All vers.) and last space before the

How carefully Prov. listened.

there are quite a few values similar so what I need is to get the values after the last ) in the values..

mahalo, Brew

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-02 : 17:01:36
this?

SELECT RTRIM(LTRIM(CASE WHEN CHARINDEX(')',Field) > 0 THEN STUFF(yourfield,1,CHARINDEX(')',Field),'') ELSE Field END))
FROM Table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

oasis1
Starting Member

35 Posts

Posted - 2012-10-02 : 17:04:58
Genius !!!! Much Mahalo !!!

quote:
Originally posted by visakh16

this?

SELECT RTRIM(LTRIM(CASE WHEN CHARINDEX(')',Field) > 0 THEN STUFF(yourfield,1,CHARINDEX(')',Field),'') ELSE Field END))
FROM Table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-02 : 17:22:43
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -