September 17, 2012 at 11:27 am
I have the table like this:
CREATE TABLE #TEMP(GROUP_ID NCHAR(50),
TEXT VARCHAR(MAX))
INSERT INTO #TEMP
SELECT '100','The purpose of this group 100 is to know the .....'
UNION ALL
SELECT '1000','The prupose of the group 1000 is to get ...'
UNION ALL
SELECT '1230', 'This is sample text 1230....'
Result:
Group_ID Text
100 The purpose of this group 100 is to know the .....
1000 The prupose of the group 1000 is to get ...
1230 This is sample text 1230....
Now i need to search for Group_ID in text column and replace with empty string.
Result should like:
100 The purpose of this group is to know the .....
1000 The prupose of the group is to get ...
1230 This is sample text ....
I tried by using replace function but its not working to replace value from other column.
select REPLACE(text,Group_ID,' ')
from #temp
Can anyone have idea about this..
September 17, 2012 at 11:36 am
From your table design, I would say is a problem with trailing spaces.
Try this and tell us if it worked.
select REPLACE(TEXT,RTRIM(Group_ID),' ')
from #temp
September 17, 2012 at 11:48 am
Why don't you take the group numbers out of the insert text?
September 17, 2012 at 11:52 am
Animal Magic (9/17/2012)
Why don't you take the group numbers out of the insert text?
Maybe because he can't control the past and have to correct the data.
Prevention is key, but you can't change the past.
September 17, 2012 at 12:07 pm
Fair enough 🙂 Am sure your suggestion will sort the issue anyway
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply