CREATE TABLE tab_update (id TINYINT,n1 NVARCHAR(30),v1 NVARCHAR(30),s1 NVARCHAR(30))
INSERT INTO tab_update (id,n1,v1,s1)
SELECT 1,‘天‘,‘土豆‘,‘章子怡‘
UNION ALL
SELECT 2,‘集团‘,‘黄瓜‘,‘汪峰‘
UNION ALL
SELECT 3,‘宇宙‘,‘茄子‘,‘杰克隽逸‘
UNION ALL
SELECT 4,‘海洋‘,‘西红柿‘,‘刘德华‘
UNION ALL
SELECT 5,‘大学‘,‘莲藕‘,‘凤凰传奇‘
SELECT * FROM tab_update
DECLARE @var NVARCHAR(30)
UPDATE tab_update
SET
@var=n1, --传递值交换
n1 = v1,
v1 = s1,
s1 = @var
SELECT * FROM tab_update
DROP TABLE tab_update
时间: 2024-10-27 02:15:00