如何在MS SQL Server中插入子选择的内容?

MrD*_*ase 3 sql-server

我想做点什么

insert into my table (select * from anothertable where id < 5)
Run Code Online (Sandbox Code Playgroud)

什么是正确的MSSQL语法?

谢谢!

Ed *_*fer 5

这是你在找什么?

INSERT INTO MyTable
SELECT * FROM AnotherTable
WHERE AnotherTable.ID < 5
Run Code Online (Sandbox Code Playgroud)