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)
 Update in While loop

Author  Topic 

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-05-25 : 02:45:58
Dear All

The following statement taking more time(this query is in while loop )the table tmp_one having clustered index on sno column

UPDATE tmp_one
SET amount = STUFF(amount,1,0,' ')
WHERE DATALENGTH(LTRIM(amount)) < 5 + @pamt
AND tmp_one .sno = @sno

is there any wrong with my query. Please give me ur valuable suggession


Thanks
KK

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-25 : 07:11:11
How many rows does the table have?
What is the datatype of amount column?

Madhivanan

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

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-05-25 : 09:06:46
Ur While loop may be causing the time killing

Do u have a few values for @pamt, & @sno ?
Can't u add that calculation to the Query itself ?
Is this in a cursor ?

If u can place the While loop as well, v may be able to help u.

Srinika
Go to Top of Page
   

- Advertisement -