SQL Server Performance

How to use REPLACE function on ntext data type

Discussion in 'SQL Server 2005 General Developer Questions' started by haresh, Jan 14, 2007.

  1. haresh New Member


    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?


  2. FrankKalis Moderator

    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
    Microsoft SQL Server MVP
  3. haresh New Member

    I am using SQL server 2000.

    My query is as below:

    update tblCampaignEmails set ceEmailContent = replace(ceEmailContent,'{%Email%}','haresh@domain.com') where ceCampaignEmailID = 8


    Server: Msg 8116, Level 16, State 1, Line 1
    Argument data type ntext is invalid for argument 1 of replace function.

    I want to replace {%Email%}, {%FirstName%}, {%LastName%} etc.. with respective values.


  4. madhuottapalam New Member

    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.


  5. haresh New Member

    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.


  6. MohammedU New Member

Share This Page