Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
laddu
Constraint Violating Yak Guru
332 Posts |
Posted - 2009-06-24 : 00:53:47
|
| Can anyone explain the difference? when to use them? Thanks! |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-24 : 01:33:52
|
A cursor is (in my words) a record set and functionality / abitlity to process the rows from that record set one by one.Cursors are very slow! In most cases you don't need cursors if you are thinking set based.A table variable is a variable that can be used like an ordinary table. You can find many examples in this forum for using table variables to provide sample data or to return a table (variable) from a function.Hope that helps.Webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-24 : 01:36:46
|
when to use them?cursor : don't use them. Bad for performancetable variable : OK KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Directory
Starting Member
5 Posts |
Posted - 2009-06-24 : 01:38:02
|
| those topic will helpful to youhttp://www.lazydba.com/sql/1__13921.htmlhttp://www.sqlteam.com/article/cursor-performanceConclusion: cursor can do processing one row at a time.table variable can process look like temp table.It can process multiple rows.:) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-24 : 02:04:37
|
Table variables can be bad when populated with more than one page of data.Since there is no statistics for table variables, sql engine always assumes there is one record, and one record only, in the table variables which can lead to bad query plans. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|