SQL Server Basic Cursor for SELECT and UPDATE Operations

preview_player
Показать описание
Here's a quick overview of how to write and use a basic cursor in SQL Server's T-SQL.

00:00 - Introduction
00:32 - SELECT Cursor
02:22 - Don't Forget to do this!!!
03:20 - Cursor Problems
03:40 - UPDATE Cursor
06:16 - Suppressing Cursor Output

Cursors are really useful if you want to perform a specific action on all of the rows in a particular database table. They are especially well suited to task-based rather than set-based processes that have to call an external function or resource on each row, for example calling a component to add data to a messaging queue or send an email.

The downside to cursors is that their performance can be slow, so it's best to avoid using them on very large tables or when query performance is important.

Cursors used to be one of the only ways of performing certain actions on every row in a table. However, be aware that there are alternatives, such as using a WHILE EXISTS loop or the more recent T-SQL Common Table Expressions (CTE).

If you found this video leave a LIKE and SUBSCRIBE for more coding and database programming videos.

Рекомендации по теме
Комментарии
Автор

Hey there, kudos your efforts..Please i have a simple enquiry as a newbie..What is the main difference between cursor and view in sql? Thanks a lot.

hasanmougharbel