How to use REPLACE function on ntext data type | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to use REPLACE function on ntext data type

Hello, I have a column of type ntext in table contains mail body. When I send this mail to users I want to replace some tags with user specific data. I tried to use REPLACE on ntext but it’s giving me error. So can anyone help me how can I resolve this problem? Thanks, Haresh

What error are you getting? If you are on SQL Server 2005, change NTEXT to NVARCHAR(MAX) and all of a sudden all string function are available to you. Which version are you using and what does your code look like? —
Frank Kalis
Moderator
Microsoft SQL Server MVP
Webmaster:http://www.insidesql.de
I am using SQL server 2000. My query is as below: update tblCampaignEmails set ceEmailContent = replace(ceEmailContent,'{%Email%}’,’[email protected]‘) where ceCampaignEmailID = 8 Error: Server: Msg 8116, Level 16, State 1, Line 1
Argument data type ntext is invalid for argument 1 of replace function. Note:
I want to replace {%Email%}, {%FirstName%}, {%LastName%} etc.. with respective values. Thanks, Haresh

You are posting this in SQL 2005 forum and probably u might not get the actual answer as you disre. Try to post under correct forum. These datatype has lot of limitation and your variable is of these type, you have to look for some workaround. this link is not a solution to your proble. I have seen something like this in net but i am not able to get it right now. Anyhow have a look at this, it may lead in right direction. Meanwhile, i will search for the actual one, i have seen workaround for this.
http://sqljunkies.com/WebLog/amachanic/articles/PatternReplace.aspx Madhu
Hello Madhu, Thanks for your answer. I think the link you posted can’t handle ntext. I am also trying from my side. If you find any article related to this problem then please update me. Thanks, Haresh

There is no easy way for this… but the following thread may help you.. http://www.thescripts.com/forum/thread79200.html
Mohammed U.
]]>