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 2008 Forums
 Other SQL Server 2008 Topics
 Replace Funrtion

Author  Topic 

Latha27
Starting Member

20 Posts

Posted - 2012-03-15 : 12:31:07
Is there a better way to do this replace function. I have like this more than 100 ID's. And all i want is in the (ZZZZZ),(YYYY 123)

ID Name
001 AA-111(ZZZZZ)
002 AA-23 B456(ZZZZZ)
003 AA-2222(ZZZZZ)
004 AA-1256 AAXC(YYYY 123)
005 AA-156 ABXC(YYYY 123)

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-03-15 : 12:33:13
SELECT STUFF(Name,1,CHARINDEX('(',Name)-1,'')
FROM myTable
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-15 : 15:52:27
[code]
SELECT RIGHT(Name,LEN(Name)-CHARINDEX('(',Name)+1)
FROM myTable
[/code]

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

Go to Top of Page
   

- Advertisement -