Hi Friends,
I am not lazy today, just physically conservative 🙂 –so a small post and only scripts ! 🙂
—Â FUN with row constructors
use tempdb go create table amit1 (name varchar(20), age int); go create table amit2 (name varchar(20), age int); go
— Insert multiple records
INSERT INTO amit1 VALUES('Amitabh', 5), ('Abhishek', 6); go SELECT * FROM amit1 go
–Now try this: does this work?
INSERT INTO amit2 VALUES ((SELECT Name FROM amit1), (SELECT Age FROM amit1)) go
–what about this?
INSERT INTO amit2 VALUES ((SELECT TOP(1) Name FROM amit1), (SELECT TOP(1) Age FROM amit1)) go select * from amit2 GO
— Have fun with Row constructors