How do I execute the same SQL code multiple times?
June 22, 2008
Use the command GO. The following example demonstrates how GO can be used to execute the same code multiple times.
SELECT GETDATE() AS CurrentTime GO 3
The result below will be displayed with “Result to Text” mode turned on.
CurrentTime
———————–
2008-06-20 11:52:54.200 (1 row(s) affected)CurrentTime
———————–
2008-06-20 11:52:54.217 (1 row(s) affected)CurrentTime
———————–
2008-06-20 11:52:54.217 (1 row(s) affected)
Entry Filed under: SQL Scripts. Tags: code, execute, GO, multiple, repeat, sql, times.
Trackback this post | Subscribe to the comments via RSS Feed