Click here to Skip to main content
15,906,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hie,
I have a table which has certain feilds in which i need to show the Id values in a temporary variable.

My Table:
prodId totalQuantity ProdDesc
387 5 adjfhdjhfj
422 4 adkfdkjfl
1218 3 djkfjldkjfkasj
1975 2 lksdjfkldjflk
2600 4 dksjfkldjlsfk
8082 8 sljdflsdj
13386 5 ddkjf ;sd
20964 9 dkljflksji
29826 4 dl;kf;as
40812 1 ieruioeuioakjd

Req O/P as, i want show every data in temp variable. like ..

@vPid = 387,@vtotalQuant = 5,@vProdDesc = adjfhdjhfj
@vPid2 = 422,@vtotalQuant = 4,@vProdDesc = adkfdkjfl
@vPid3 = 1218,@vtotalQuant = 3,@vProdDesc = djkfjldkjfkasj
@vPid4 = 1975................
like wise for all the data in prodid , totalquantity proddesc.

Please Help.
Thanks in Advance. :)

Edit - from OP's own solution mistakenly posted as answer.
Hi,
Actually i have a design page in which i have 1 to 8 flags to display the data..
like ex: flag 1 : prodid,desc and quantity.
flag 2: prodid2,desc and qty. so on..till flag 8.
And so i need to send these detail's page to every users.
but the condition is , the same data must not appear in next loop, when i send the details to the users.
this way i need to also maintain a log table.


I hope i could explain the need and requirement. I would like to write down a funtion on this requirement.

Please Help.
Thanks in Advance.
Posted
Updated 29-Jun-15 4:15am
v5
Comments
Tomas Takac 29-Jun-15 2:36am    
Why? What do you plan to do with the variables?
Suvendu Shekhar Giri 29-Jun-15 2:48am    
Why not create a table variable?
Table Variable in SQL Server

It would be easier to suggest correct solution/design if we know your requirement.

1 solution

This seems like a homework. We won't give you a precise answer however we can give you the tip so that you could rest of the task yourself.

How to use Cursor in Sql[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900