How to append data from a varchar column to a text column

I have a varchar(1000) column with data that I need to append to a text column in the same table.  How do I do it?

I have tried

UPDATE    Person
SET              Comments = Comments + ' - ' + Web


but that gives me the 'invalid operator for data type' error.  I tried ampersands as well.
LVL 1
abenageAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you cannot "append" to TEXT fields... with UPDATE, you need UPDATETEXT:
http://technet.microsoft.com/en-us/library/ms189466.aspx

will not be as easy as that...
0
 
Rick_RickardsCommented:
If you're willing to create an ODBC connection and then use Access to link to the SQL Server table in question you may find the task to be considerably simpler.  In such a case a query like the one below will do the job...

UPDATE [YourTableNameHere] SET [YourTableNameHere].[Comments] = [YourTableNameHere].[Comments] & " - " & [YourTableNameHere].[Web];
0
 
Rick_RickardsCommented:
If you'd prefer not to use the Access approach you could create a view like the one below...

SELECT     Comments, Comments + N' - ' + Abv AS CommentsAndWeb
FROM         dbo.YourTableName

After you run the query you can the copy and paste the contents from the 2nd column named CommentsAndWeb and Paste them into the 1st column named Comments
0
 
Anthony PerkinsCommented:
Rick_Rickards,
Unfortunately, you cannot concatenate values with a data type of text.

As angelIII has pointed out the only way to do it in SQL Server 2000 is using UPDATETEXT.

If the text is not more than 8000, than you can CAST to varchar(8000) before concatenating.
0
All Courses

From novice to tech pro — start learning today.