tags:

views:

27

answers:

2

How can I order data in a cursor? Can we use the order by clause? Because I need to sort the data first.

thanks

+1  A: 

I am not sure what database you are using but it is possible in SQL Server.

for e.g.:

DECLARE vendor_cursor CURSOR FOR SELECT VendorID, Name FROM Purchasing.Vendor WHERE PreferredVendorStatus = 1 ORDER BY VendorID

ARS
+1  A: 

I know there was some problem with that but it can be solved using select * from (select a, b from t order by a)

sax
ahaaaaaaaaa....great ideaa...thx sax
leonita
mmmhmm..its kind a weird...yesterday i tried to used order by in cursor, and it was failed...and now its work....i still dnt get it whrs the fault..
leonita