RSS

Update data from one existing row to another existing row

12 Jun

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!

Advertisements
 
Leave a comment

Posted by on June 12, 2013 in SQL

 

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: