Tom Auger (taugr)

Coding, researching, and teaching with AI

August 8, 2018 ยท 5 min read
SQL

Repeat a SQL command multiple times

Archived from the old blog. Original URL: https://tomauger.gitlab.io/posts/2018-08-08-repeat-sql-command/.

How to repeat a SQL command multiple times

To run a SQL command multiple times use the Go command and pass the number of times you want to execute the command as a parameter:

INSERT INTO [MyTable] (fruit, quantity) VALUES ("Banana", 12);
GO 5

The above command repeats the INSERT command 5 times. This behaviour can be useful if you want to populate a database table with some test data. This command came in handy recently when I needed to fill a database table with 150 rows so I could see how a webpage I was writing looked when there were lots of data.

References