all groups > sql server (alternate) > august 2006 >
You're in the

sql server (alternate)

group:

Is there a way to transfer ntext data from one table to another? MSSQL2000



Is there a way to transfer ntext data from one table to another? MSSQL2000 Igor
8/29/2006 5:47:35 AM
sql server (alternate): Is there a way to transfer ntext data from one table to another?

I tried this

UPDATE [projects]

SET [description] = (SELECT [description_ntext] FROM [table] WHERE
[id]=1)

WHERE [id_project] = 1;


and this

DECLARE @DESCRIPTION ntext

SET @DESCRIPTION = (SELECT [bids].[bid_conditions] FROM [bids],
[projects] WHERE [bid_accepted_id] = [bids].[id_bid] AND [id_project] =
@ID_PROJECT);

UPDATE [projects]

SET [description] = @DESCRIPTION

WHERE [id_project] = 1;



none of those work in MSSQL2K,
error reported is "The text, ntext, and image data types are invalid
for local variables."
Re: Is there a way to transfer ntext data from one table to another? MSSQL2000 Erland Sommarskog
8/29/2006 9:37:56 PM
Igor (jerosimic@gmail.com) writes:
[quoted text, click to view]

It appears that you have to use the JOIN syntax, as in this example:

CREATE TABLE #projects (id int NOT NULL,
description ntext NULL)
go
CREATE TABLE #t (id int NOT NULL,
descr ntext NOT NULL)
go
INSERT #projects (id) VALUES(21)
INSERT #t(id, descr) VALUES (1, replicate('ABCD', 1000))
go
UPDATE #projects
SET description = t.descr
FROM #projects p
CROSS JOIN #t t
WHERE t.id = 1
AND p.id = 21
go
SELECT * FROM #projects
go
DROP TABLE #projects, #t

Note that if you are on SQL 2005, there is no reason to struggle with
ntext. Use nvarchar(MAX) instead, which is a first-class cititez, but
can fit just as much data as ntext.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: Is there a way to transfer ntext data from one table to another? MSSQL2000 Igor
8/30/2006 3:25:37 AM
OK thank you, I will try your solution. Unfortunately i'm limited to
MSSQL 2000 but thank you for you suggestion.

[quoted text, click to view]
AddThis Social Bookmark Button