0

I'm using SQL Server.

Can any one help me organize the syntax and difference between

cursor and cross apply' ?

Update: my intention is:

I have one user-SP_1 which gets a varchar "id" as param. I have built another user-SP_2 that gets manay "ids", parse them and then I want to send them to user-SP_1 in a loop.

Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • 3
    Those are totally different things - you're comparing an apple to a Space Shuttle..... where to start with the differences....... maybe some context would help - what are you trying to do where you have cursors vs. cross apply as options?? – marc_s Feb 13 '12 at 08:32
  • I have one user-SP_1 which gets a varchar "id" as param. I have built another user-SP_2 that gets manay "ids", parse them and then I want to send them to user-SP_1 in a loop. – Elad Benda Feb 13 '12 at 09:39
  • @EladBenda: Can you add the structures of the relevant tables to your question? It sounds as though a relatively simple query could be written to return the required data, but in order to do so we would need to know the table structures. –  Feb 13 '12 at 10:23

1 Answers1

0

Cursors allow you to loop through data one record at a time. They are generally discouraged because they are ridiculously slow compared to set based operations, and I would venture to say that the need for them is most often caused by a poor database design. They are nonetheless necessary sometimes though.

Here is a good SO page on Cross Apply: When should I use Cross Apply over Inner Join?

I suspect that one of these two things isn't quite what you are thinking it is though since as marc_s said they are completely different things. So let us know what you're trying to accomplish if you need more help.

Community
  • 1
  • 1
Brandon Moore
  • 8,590
  • 15
  • 65
  • 120