SQL Server Cursor

Cursors are not the best solution when talking about performance but,

If you run into issues with another coding technique and need to get something done quickly, using a cursor may be a viable alternative. It may take longer to process the data, but the coding time might be much less. If you have a one-time process or nightly processing, this could do the trick.

This article contains a good description, example and alternatives to cursors.

https://www.mssqltips.com/sqlservertip/1599/sql-server-cursor-example/