Click here to Skip to main content
15,881,852 members
Home / Discussions / Database
   

Database

 
AnswerRe: for loop in stored procedure Pin
Colin Angus Mackay9-Oct-07 0:09
Colin Angus Mackay9-Oct-07 0:09 
GeneralRe: for loop in stored procedure Pin
Sonia Gupta9-Oct-07 0:32
Sonia Gupta9-Oct-07 0:32 
GeneralRe: for loop in stored procedure Pin
Sonia Gupta9-Oct-07 0:51
Sonia Gupta9-Oct-07 0:51 
GeneralRe: for loop in stored procedure Pin
Krish - KP9-Oct-07 0:58
Krish - KP9-Oct-07 0:58 
GeneralRe: for loop in stored procedure Pin
GuyThiebaut9-Oct-07 1:05
professionalGuyThiebaut9-Oct-07 1:05 
GeneralRe: for loop in stored procedure Pin
Colin Angus Mackay9-Oct-07 2:14
Colin Angus Mackay9-Oct-07 2:14 
GeneralRe: for loop in stored procedure Pin
GuyThiebaut9-Oct-07 2:22
professionalGuyThiebaut9-Oct-07 2:22 
GeneralRe: for loop in stored procedure Pin
Colin Angus Mackay9-Oct-07 3:00
Colin Angus Mackay9-Oct-07 3:00 
GuyThiebaut wrote:
Yes I know it is possible to write a query without the use of a cursor (I'll be damned if I know how to do this though).


You have to write a query to populate a cursor in the first place. Therefore you must know how to write some queries.


GuyThiebaut wrote:
I think unless the application is for some huge banking corporation or airline then using a cursor should be fine.


That's your opinion, and I, along with many qualified DBAs that I know, disagree with it.


GuyThiebaut wrote:
What would you suggest instead of cursors?


Write set based queries where possible. Never consider a cursor until all other avenues are exhausted.

SQL Server, along with many other RDBMS systems, works best when dealing with sets of data. It does not work well when dealing with individual rows.

SQL is a declarative language - you declare what you want and then leave it up to the database engine to figure out how to get it. When you use cursors you introduce an element of procedural programming in to it. That means you are forcing it to do it HOW you tell it, which is often not the best way.

There are some situations where CURSORs are needed, e.g. recursive data. But SQL Server 2005 and 2008 are eliminating those cases also with additions to SQL.

At the end of the day there is no single answer as to what you should replace a cursor with because there are many situations where they can be used when they shouldn't.


Upcoming FREE developer events:
* Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ...

My website

GeneralRe: for loop in stored procedure Pin
GuyThiebaut9-Oct-07 3:16
professionalGuyThiebaut9-Oct-07 3:16 
AnswerRe: for loop in stored procedure Pin
Christian Graus9-Oct-07 14:39
protectorChristian Graus9-Oct-07 14:39 
QuestionStoring RTF in SQL Pin
MartyK20078-Oct-07 22:47
MartyK20078-Oct-07 22:47 
AnswerRe: Storing RTF in SQL Pin
Colin Angus Mackay9-Oct-07 0:13
Colin Angus Mackay9-Oct-07 0:13 
GeneralRe: Storing RTF in SQL Pin
MartyK20079-Oct-07 0:39
MartyK20079-Oct-07 0:39 
GeneralRe: Storing RTF in SQL Pin
MartyK20079-Oct-07 1:05
MartyK20079-Oct-07 1:05 
QuestionCreating Virtual Directories in Reporting Services Pin
Karuna Kumar8-Oct-07 20:44
Karuna Kumar8-Oct-07 20:44 
AnswerRe: Creating Virtual Directories in Reporting Services [modified] Pin
John Gathogo8-Oct-07 23:18
John Gathogo8-Oct-07 23:18 
QuestionJoining 2 Tables Pin
Brendan Vogt8-Oct-07 20:22
Brendan Vogt8-Oct-07 20:22 
AnswerRe: Joining 2 Tables Pin
Krish - KP8-Oct-07 21:09
Krish - KP8-Oct-07 21:09 
QuestionSQL 2005 SQL Profiler? Pin
devvvy8-Oct-07 16:35
devvvy8-Oct-07 16:35 
Answerfound one --- Re: SQL 2005 SQL Profiler? Pin
devvvy8-Oct-07 18:41
devvvy8-Oct-07 18:41 
QuestionIntermittent errors..please help!!! Pin
new_phoenix8-Oct-07 10:51
new_phoenix8-Oct-07 10:51 
AnswerRe: Intermittent errors..please help!!! Pin
andyharman9-Oct-07 1:30
professionalandyharman9-Oct-07 1:30 
QuestionVISTA and SQL SERVER 2005 Pin
Yoyosch8-Oct-07 7:23
Yoyosch8-Oct-07 7:23 
AnswerRe: VISTA and SQL SERVER 2005 Pin
Andy_L_J9-Oct-07 22:19
Andy_L_J9-Oct-07 22:19 
QuestionODB Problem ? Pin
hungdl8-Oct-07 6:36
hungdl8-Oct-07 6:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.