Google+ Followers

Monday, June 17, 2013

Update data from one existing row to another existing row

Update data from one existing row to another existing row

review the following example

CREATE TABLE #abc(
id int,
Name varchar(50),
SurName varchar(50)
)
Insert into #abc values (1,'Anil','Shah')
Insert into #abc values (2,'Kuldeep','singh')
Insert into #abc values (3,'Waheed','panjri')
Insert into #abc values (4,'Sumit','sutar')

Select * From #abc

Update #abc Set Name= c.Name,
SurName=c.SurName From
(Select Name,SurName From #abc Where id=1)c
Where id=4

I hope this helps, good luck!

 

No comments:

Post a Comment