March 12, 2006 at 2:41 pm
I would like to take row in a table and update other existing rows so they copy all columns of this row exactly, (except the PK of course).
Is there a short way of doing this without lots of variables and update, (SET x = @x) statements?
March 12, 2006 at 3:03 pm
UPDATE MyTable
SET ColA = A.ColA,
ColB = A.ColB,
....
FROM MyTable A
WHERE A.ColX = @Value
_____________
Code for TallyGenerator
March 16, 2006 at 2:59 am
try this one :
declare @colA varchar(50),@colB varchar(50),@colC varchar(50)
select @colA=colA,@colB=colB,@colC=colC from tblX
where id = '1' -- this is the one that you want to get the data from
update tblX
set colA=@colA,colB=@colB,colC=@colC
where id <> '1'
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply