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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mass UPDATE query based on compared VARCHAR values

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
Hi everyone,

I'm trying to run an UPDATE sproc en masse to tally the results of a voting app I built for the upcoming NCAA March Madness tournament. I'm trying to update a master table with the value of a computed column.

If two fields match (SELECTEDWINNERS and REALLIFEWINNERS), then the value of an INT field, TOTALTALLY, is multiplied by the value of POINTVALUE.

I tried this, to no avail:

UPDATE (
SELECT
CASE WHEN SelectedWinners = RealLifeWinners THEN (TotalTally * PointValue) ELSE '0' END
AS [NewPoints]
FROM NCAATable
) AS [Tourney]
SET TotalTally = ReassignedPoints

Can someone help me to write a sproc that executes such an UPDATE operation all at once?
 
I'm not completely sure what you are trying to do, but take a look at this. Does it make sense? Does it help?

Code:
UPDATE NCAATable
Set Total = 
        CASE WHEN SelectedWinners = RealLifeWinners THEN (TotalTally * PointValue) ELSE '0' END

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Glad to help.

NCAA.... Is that like NASCAR. I love it when those Hockey player get 3 pointers from the end zone. [bigsmile]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top