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
 General SQL Server Forums
 New to SQL Server Programming
 How to Find Out Values

Author  Topic 

yaman
Posting Yak Master

213 Posts

Posted - 2008-09-16 : 10:06:49
Sir ,
I am Using While loop in place of Cursor .
I want one by one record from table and perform Some action using
Fetch Record .

Like I am Fetching Itemid From Item table
Used That Itemid I am update Item table

Sir How i am Find Item id One by One Like Cursor in to andther temporary variable ?

Yaman

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-16 : 10:09:13
[code]DECLARE @ID int

SELECT @ID=MIN(PK)
FROM YourTable

WHILE @ID IS NOT NULL
BEGIN
... perform your looping operation

SELECT @ID=MIN(PK)
FROM YourTable
WHERE PK>@ID
END[/code]


PK is primary key
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-09-16 : 10:18:27
Why notuse set based logic instead of a loop?

Post your code



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -