Sam*_*lly 3 sql-server sql-server-2008
使用SQL Server 2008 R2
显然可以做到
INSERT INTO Table1 SELECT * FROM Table1 where Id=1234
Run Code Online (Sandbox Code Playgroud)
但在SQL Server中,这不起作用.我是否认为SQL Server不支持上述INSERT语句,并且需要专门指定列.
谢谢.
编辑
上面的SQL不完整,现在已经更正
您错过了要插入的表的名称
insert into destination_table
select * from source_table
Run Code Online (Sandbox Code Playgroud)
当然,这仅适用于具有相同列的表.如果您只想插入特定列,则还需要指定它们
insert into destination_table (col1, col2)
select col7, col3 from source_table
Run Code Online (Sandbox Code Playgroud)