Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set-based versus Cursors 1

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
hello everyone,

Several of you, SQLSister and others, have said that set-based processing is far better than using cursors.

Can anyone give me an example of what set-based code or technique would lokk like ?

Thanks, John
 
Set-based just means using an INSERT/UPDATE etc on a set of data at a time, rather than cycling through and executing it once for each row. You use set-based processing all the time, eg:

Code:
UPDATE t
SET c1 = 123
WHERE id = 1

This would be far better than using a cursor to loop through each row, checking the id and updating one at a time.

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top