Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculating values for earch record with SP at once..

Status
Not open for further replies.

jonasggg

Technical User
Sep 30, 2003
12
0
0
UY
hello,

I imported a table to sql server which it hasnt identity field. I created a field now but how can I give the correlative numbers at once in Stored Procedure to all the records? thank in advance.
For example ->
name last_name Cnt price total
John Smith 1 10
Sarah Smith 1 15
Marta Smith 1 13

to:

id name last_name Cnt Price Total
1 John Smith 1 10
2 Sarah Smith 1 15
3 Marta Smith 1 13


Another thing..
how can I calculate the total (cnt x price) at once for each records?
Thanks!!
 
The ID field should populate automatically if you really made it an Identity....

the total field isn't necessary, you should be doing these calculations elsewhere (stored proc when needed, view, etc.)

but if you really want it...
Code:
update tableName
set total = cnt * price


"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top