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
 Transact-SQL (2000)
 sp tuning

Author  Topic 

markth
Starting Member

1 Post

Posted - 2005-07-23 : 21:58:04
I use this store procedure
My table have thirty thousands record
But running more than 30 hours..
any better method ? thanks a lot
============================================================
declare @No varchar(12)
Declare A_cur Cursor for

Select No from CUSTNo order by No
OPEN A_cur
FETCH NEXT FROM A_cur INTO @No

WHILE (@@FETCH_STATUS=0)

BEGIN


select @A1=Min(CUSTVALUE) from CUSTVALUE where No=@No


SELECT @A2= ID FROM (
select ID AS ID from CUSTDATA1 where No=@No
union
select ID AS ID from CUSTDATA2 where No=@No
)

etc.
.
.
.
.
.


Insert CUSTdetail(detail)
select @A1+@A2+@A3+@A4+@A5+...
FETCH NEXT FROM A_cur INTO @No


END

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-07-24 : 00:58:12
First, get rid of the cursor. Second, post some DDL for the tables you are referencing, make sure to include the DDL for the indexes you have.


-ec
Go to Top of Page
   

- Advertisement -