0

I'm having an article table which has a ntext column called SearchText which contains the whole article stripped for html.

When iterating through our +60000 articles I forgot to add a column to the SearchText content. I'm now trying to update the table using

update Table 
set SearchText = cast(ForgottenField as ntext) + cast(CHAR(13) as ntext) + SearchText as ntext) 
where ForgottenField <> '' 

But I get the following error:

Operand data type ntext is invalid for add operator.

I have read about UpdateText, but I can't figure out how to write some simple SQL to update the column

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    `ntext` and `text` data types will be removed in a future version of SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use `nvarchar(max)` or `varchar(max)` instead. [See details here](http://msdn.microsoft.com/en-us/library/ms187993.aspx) – marc_s Nov 29 '21 at 09:06
  • Alter your column to be `nvarchar(max)`, `Text / nText` are deprecated. It also looks like you are storing the value from n other columns in a single string column in the same table - this is not a good idea, your `SearchText` column should be in its own FK-linked table. – Stu Nov 29 '21 at 09:46

1 Answers1

0

I found this site that helped me out (as I had to update ntext too)

Updating your ntext to varchar and updating like this. update x

set x = convert(varchar(max),x) + ' xxx'
Siddhartha Mukherjee
  • 2,703
  • 2
  • 24
  • 29
ts4you
  • 1
  • 3