mssql sqlserver 数据表中数据行互换的方法分享


摘要:
下文讲述使用sqlserver数据表中数据列互换方法分享,如下所示:


例:
将下表中数据列 A和数据列B的值互换,具体实现方法如下所示:

    create table [maomao365.com]
   (keyid int identity,
    infoA varchar(10),
	infoB varchar(10)
	)
	go
insert into [maomao365.com]
(infoA,infoB)values
('1A','1B'),
('2A','2B'),
('3A','3B') 
go

select * from [maomao365.com]
go

update [maomao365.com] 
 set infoA=infoB ,
 infoB = infoA 
 go

 select * from [maomao365.com] 
go
truncate table [maomao365.com]
drop     table [maomao365.com]
mssql_sqlserver_数据列互换_9496

mssql_sqlserver_数据列互换_9496