Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

can insert into but can't update a text column
I can insert into but can't update a text column - see following example :

1) create a table with a text column

CREATE TABLE [dbo].[TestLongText] (
[Id] [int] IDENTITY (1, 1) NOT NULL ,
[FileContent] [text] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

2) insert text from another table into this table
insert into  TestLongText(FileCon
tent) select FileContent from
 OtherTableWithTextCo
l where Id = 2
-- works fine

3) try to update this text column with identical text from the other table
update TestLongText set FileContent = (select FileContent from
 OtherTableWithTextCo
l where Id = 2) where id = 1
-- returns this error: The text, ntext, and image data types are invalid in
this subquery or aggregate expression.



Report this thread to moderator Post Follow-up to this message
Old Post
David Laub
03-31-05 12:03 AM


Re: can insert into but can't update a text column
Try something like:
code:
update TestLongText set FileContent = o.FileContent from TestLongText t,OtherTableWithText Col o where o.Id = 2 and t.Id =1
Cristian Lefter, SQL Server MVP "David Laub" <dlaub@wheels.com> wrote in message news:Oa%23NfYUNFHA.3560@TK2MSFTNGP14.phx.gbl... >I can insert into but can't update a text column - see following example : > > 1) create a table with a text column > > CREATE TABLE [dbo].[TestLongText] ( > [Id] [int] IDENTITY (1, 1) NOT NULL , > [FileContent] [text] NOT NULL > ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] > > 2) insert text from another table into this table > insert into TestLongText(FileCon tent) select FileContent from > OtherTableWithTextCo l where Id = 2 > -- works fine > > 3) try to update this text column with identical text from the other table > update TestLongText set FileContent = (select FileContent from > OtherTableWithTextCo l where Id = 2) where id = 1 > -- returns this error: The text, ntext, and image data types are invalid > in > this subquery or aggregate expression. > >

Report this thread to moderator Post Follow-up to this message
Old Post
Cristian Lefter
03-31-05 12:03 AM


Re: can insert into but can't update a text column
Thanks!!  That solved it - i forgot about doing an update based on a
join instead of a subquery!



*** Sent via Developersdex http://www.examnotes.net ***

Report this thread to moderator Post Follow-up to this message
Old Post
David Laub
03-31-05 12:03 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Forum Jump:
All times are GMT. The time now is 02:08 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006