Tuesday, June 11, 2013

SQL Puzzle #2 - How to populate the same data 5 times to table without using any loop/cursor/recursive query.

We have a table, say MyTable and we want to populate data to the table using one INSERT query.
My question is, how to populate the same data 5 times to table without using any loop/cursor/recursive query.

--// Table
Create Table MyTable
(
FirstName Varchar(50),
SecondName Varchar(50)
)

--// Sample Insert query as follows;

Insert into MyTable values('Sachin','Tendulkar')

Ans:

Insert into MyTable values('Sachin','Tendulkar')

GO 5

No comments:

Post a Comment