答案 0 :(得分:22)
INSERT INTO rooms
(roomname, current_occupancy, max_occupancy, semester)
SELECT roomname, current_occupancy, max_occupancy,'spring'
FROM rooms
WHERE [semester]='fall'
(假设您的房间和占用列的名称)
答案 1 :(得分:5)
使用临时表,无论涉及多少列,都可以简化;
SELECT * INTO #ROOMS FROM ROOMS;
UPDATE #ROOMS SET SEMESTER='spring';
INSERT INTO ROOMS SELECT * FROM #ROOMS;
答案 2 :(得分:4)
Insert Into Rooms
Select col1, col2, col3, 'Spring' as Semester -- select each column in order except 'Semester', pass it in literally as 'Spring'
From rooms where
Semester = 'Fall'
答案 3 :(得分:1)
如果您只是想在Sql Server Management Studio中尝试这样做,您可以复制表,运行Update命令并将学期设置为弹簧克隆表,然后使用向导附加克隆的数据表到现有表。
如果您了解编程语言,则可以提取所有数据,修改学期,然后将数据插入现有表格。
注意:其他答案是实现这一目标的更好方法。