March 8, 2005 at 10:59 pm
DBA's or Developers ,
I'm trying to strip data from a column in a table using an UPDATE trigger. I've already created the initial logic to populate the data into column2 from column1. But I want to remove the full name (e.g. John Doe) and the parentheses (e.g. Data123).
EXAMPLE OF HOW IT LOOKS NOW:
Column1 Column2
John Doe (Data123) John Doe (Data123)
EXAMPLE OF HOW I WANT IT TO LOOK:
Column1 Column2
John Doe (Data123) Data123
Thanks!
March 9, 2005 at 1:43 am
Hi,
Try this
select column1, substring(columnn1,charindex(columnn1,'(')+1,charindex(columnn1,')') as Column2
from tbl
Helen
--------------------------------
Are you a born again. He is Jehova Jirah unto me
March 9, 2005 at 10:28 am
Helen,
Thank you! I used something similar to what you wrote and it worked.
DECLARE @In nvarchar(250)
SET @In = 'Baxter Lane (BLANE)'
SELECT SUBSTRING(@In, CHARINDEX('(', @In) + 1, CHARINDEX(')', @In) - CHARINDEX('(', @In) - 1)
David
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply