TSQL – Simple Loop Through Result Set Using Cursor Writer #1, 2013-02-01 (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. Programming SQL cursorfetchloopresult setsql serverTSQL