Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Partial string replacement

Status
Not open for further replies.

Raul2005

Programmer
Sep 23, 2005
44
US
I have the follwing:
afsfffdfREMARKSdddddd
returned on my record and I need to detect for REMARK and replace all what I have before with empty spaces so my final result will be

REMARKSdddddd

Thanks
 
If the literal "remark" could be anywhere in the string then use charindex.

What should be the result set does not contain "remark"? Do you want to return the whole text then?
Code:
select substring('afsfffdfREMARKSdddddd', charindex('demark', 'afsfffdfREMARKSdddddd'), len('afsfffdfREMARKSdddddd'))

Regards,
AA
 
Thanks amrita
I have a question..This string is returned from database and I have not control of what is going to return. sometimes it could be
udadasdREMARKnnnnn
hhhhhhhhhhhhhhhhhhhhhhhhREMARKffffffffffffffff
As you see it is not an static string and the result should be all what I have after the word REMARKS


I will appreciate any ideas
 
Plug both your examples in the code that I provided and you will see that only characters from Remark are displayed.

My question to you was, what should be the output if row does not contain remark (example hhhdemarkggg)?
 
No problem we are filtering all records that contain remarks, so all recordset will containg remarks some how..

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top