Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 nText update issue

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2010-09-29 : 01:56:53
Dear All,


update tbl1 set content=(select content from tbl1 where id=3)
where id in (4,5,6,8,9,11)


content is nText field. I getting error:- The text, ntext, and image data types are invalid in this subquery or aggregate expression.


Anyone have idea how to solved this issue.

Thank you.

Regards,
Micheale

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-29 : 02:15:24
Can you put the value into a variable first?

DECLARE @v ntext

SELECT @v = content
FROM tbl1
WHERE id = 3

UPDATE tbl1
SET content = @v
WHERE id IN (4,5,6,8,9,11)

Does that work?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

micnie_2020
Posting Yak Master

232 Posts

Posted - 2010-09-29 : 03:00:08
Dear tkizer,

I'm getting error The text, ntext, and image data types are invalid for local variables.

Anyway. I get solution dyy. Answer is


update a set content=b.content
from tbl1 a
inner join tbl1 b on b.id=3
where a.id in(4,5,6,8,9,11)


Thank you.

Regards,
Micheale
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-09-29 : 03:02:36
Can you change column to nVarchar(MAX) datatype instead? nText is deprecated and won't be supported in future versions, and nVarchar(MAX) allows string manipulations the same as ordinary nVarchar so is much more flexible.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-29 : 12:56:38
I never use text data type, so my familiarity with it is limited. Hence my bad solution!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -