Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy nText value from one record to another 1

Status
Not open for further replies.

techkate

Programmer
Joined
Feb 23, 2004
Messages
118
Location
US
This seems to be one of those concepts that I'm just not able to grasp - looked at other posts here, googled, scoured through help, and I'm still not getting it. I think I'm supposed to use UPDATETEXT, but I'm not sure how.

All I want to do is copy the value of an nText field, which I will name 'LayoutText' from one record to another, within the same table.

I get the error 'The text, ntext, and image data types are invalid in this subquery or aggregate expression' when I try this update:

Code:
declare @source_id int
declare @dest_id int

set @source_id = 1
set @dest_id = 2

UPDATE thetable
SET layouttext = (SELECT layouttext FROM thetable WHERE recordid = @source_id)
WHERE recordid = @dest_id

Thanks in advance.

Kate

[small]"Yeah, it's a non-nutritive cereal varnish. It's semi-permeable. It's not osmotic.[/small]
[small]What it does is it coats and seals the flake, prevents the milk from penetrating it."[/small]

 
Try...

Code:
Update ToTable
Set    totable.layouttext = FromTable.layouttext
From   theTable As ToTable
       Inner Join theTable As FromTable
         On FromTable.RecordId = @Source_id
         And ToTable.RecordId = @Dest_Id

Make sure you have a backup of your database before you do this.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Worked perfectly. Thanks so much.

Kate

[small]"Yeah, it's a non-nutritive cereal varnish. It's semi-permeable. It's not osmotic.[/small]
[small]What it does is it coats and seals the flake, prevents the milk from penetrating it."[/small]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top