No Image

TSQL – Simple Loop Through Result Set Using Cursor

February 1, 2013 benf101 2

(If you want to AVOID cursors, see: TSQL – Loop Through Result Set WITHOUT Cursors) This is the basic query text to use whenever you need to loop through a result set in SQL Server using TSQL.  In this example we are getting every database name and printing it out.