Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
Dear Coders,
 
I have following query..
 
I get following data when i fire a query:
 
UNITECH
PUNJLLOYD
JPASSOCIAT
HDIL
DENABANK
KOKUYOCMLN
ASHOKLEY
IOB
 
Now what i want to do is when i get this data then one by one i want to update the records one by one based on the values which i got above.
 
For e.g.After getting the above records i want to update some columns based on formula.The formula will be same for all these records.
 
Basically this are stock names & i want to update the stock moving AVG based on the condition.
 
Can this done in one query?
 
Thanks & Regards.
Posted 26-Nov-12 5:38am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There is new feature Merge in SQL Server 2008 which is replacement of Cursor.
 
You can refer below articles to solve your problem:
Merge Statement in SQL Server 2008[^]
 
http://blog.sqlauthority.com/2008/08/28/sql-server-2008-introduction-to-merge-statement-one-statement-for-insert-update-delete/[^]
 
Thanks,
Jitendra
  Permalink  

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

  Print Answers RSS
0 Nirav Prabtani 343
1 OriginalGriff 207
2 Mika Wendelius 185
3 CPallini 179
4 Sergey Alexandrovich Kryukov 176
0 Nirav Prabtani 398
1 OriginalGriff 292
2 Sergey Alexandrovich Kryukov 251
3 Mika Wendelius 185
4 Abhinav S 180


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100