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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Comparing Temp table and cursors

Author  Topic 

Radhiga
Starting Member

35 Posts

Posted - 2006-04-13 : 01:28:51
Hai friends,
i need to decide, whether i want to use cursor or temp table for my requirment. pls help me. the requirment is like this,
i will have two different resultset(this resultset only i need to finalisize either cursor or temp tbl). need to compare both the resultset and need to append the second result set into the first result set.
what shall i use here...which will affect the performance..
Guide me.....

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-04-13 : 01:40:35
Its better to use temp tables then the cursors since amount of time requires for processing the cursor will be more. and also cursors takes lots of server memory to excute..

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-13 : 01:53:40
or use table variable if the number of records is not to huge. Try to avoid cursor unless necessary.



KH


Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2006-04-13 : 03:12:23
Although I don't know the specifics of what you are trying to accomplish, I'd say go with temp tables or table variables.

When you say “append” that leads me to believe that you might be able to do some sort of LEFT OUTER JOIN to avoid using a temp table altogether. If that is a possibility, then you should run some tests and see which performs the best.

-Lamprey
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-13 : 03:27:23
>>need to compare both the resultset and need to append the second result set into the first result set.

Use Union All to append second result to first
Otherwise give more details on what you are trying to do

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Radhiga
Starting Member

35 Posts

Posted - 2006-04-13 : 04:47:54
Thanks for the reply Friends...Any we decided to go with cursor for this requirment as i need to loop thro each record, compare with first set and then append it
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-13 : 04:58:39
Post some sample data and the result you want
There may be better method than what you wanted to use

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -