RSS

Tag Archives: update

Swap Value Between Two Row Of Columns In MS-SQL

Swap Value Between Two Row Of Columns In MS-SQL

Following Code Will Help you to Swap Value Between Two Row Of Columns In MS-SQL

 begin tran

declare @sum int

select @sum = sum(DisplaySeq)
from CustomCatalogForm
where CustomCatalogFormId in (1,2)

update CustomCatalogForm
set DisplaySeq = @sum - DisplaySeq
where CustomCatalogFormId in (1,2)

commit tran

I hope this helps, good luck!

 

Tags: , , ,

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!

 
Leave a comment

Posted by on June 12, 2013 in SQL

 

Tags: , ,