Answered by:
How to update an HTML element in a string

Question
-
Answers
-
Hi wakefun,
Could you please share us your table structure (CREATE TABLE …) and some sample data(INSERT INTO …) along with your expected result? So that we’ll get a right direction and make some test.
Or please try it.
replace(@xml,'<BaseUrl>A</BaseUrl>','<BaseUrl>string to be replace</BaseUrl>')
Best Regards,
Rachel
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by wakefun Tuesday, October 8, 2019 1:53 PM
All replies
-
Can you show and example?
SELECT REPLACE(@str,'<BaseUrl>','</BaseUrl>' )
Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting: Large scale of database and data cleansing
Remote DBA Services: Improves MS SQL Database Performance
SQL Server Integration Services: Business Intelligence
-
Hi wakefun,
We can use REPLACE or STUFF or SUBSTRING Function based on inputs.
Can you attach any real example and expected output of it, to proceed in the correct direction.
Please mark this as answer if it solved your issue.
Please vote this as helpful if it helps to solve your issue.
Thanks,
Arulmouzhi
-
-
If you never need the original Url, or can save it separately, then do not store it inside this field. Keep just a placeholder or an empty element like this: “<BaseUrl/>”. Then you can use a simple REPLACE(myfield, ‘<BaseUrl/>’, ‘<BaseUrl>‘ + newUrl + ‘</BaseUrl>’), which can be also done in non-SQL modules.
If it is a valid XML (XHTML), then probably you can also use the XML features.
- Edited by Viorel_MVP Monday, October 7, 2019 11:51 AM
-
Hi wakefun,
Could you please share us your table structure (CREATE TABLE …) and some sample data(INSERT INTO …) along with your expected result? So that we’ll get a right direction and make some test.
Or please try it.
replace(@xml,'<BaseUrl>A</BaseUrl>','<BaseUrl>string to be replace</BaseUrl>')
Best Regards,
Rachel
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by wakefun Tuesday, October 8, 2019 1:53 PM