Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 run update statements off pivot table data?

Author  Topic 

mxfrail
Yak Posting Veteran

84 Posts

Posted - 2009-05-13 : 12:10:29
I am using a sql pivot to display data. And I am allowing the user to change data with in asp.net.

On update I need to run the follow lines of code -

UPDATE tblSalesQuotas SET Quota = @Qtr1 WHERE (RepID = @repid) AND (intYear = @intyear AND (intQtr = 1)
UPDATE tblSalesQuotas SET Quota = @Qtr2 WHERE (RepID = @repid) AND (intYear = @intyear) AND (intQtr = 2)
UPDATE tblSalesQuotas SET Quota = @Qtr3 WHERE (RepID = @repid) AND (intYear = @intyear) AND (intQtr = 3)
UPDATE tblSalesQuotas SET Quota = @Qtr4 WHERE (RepID = @repid) AND (intYear = @intyear) AND (intQtr = 4)


Is there anyway I can do this? Within my sqlsource in asp.net I can only least 1 statement. So I cannot just enter that in and go.

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2009-05-13 : 12:58:27
UPDATE tblSalesQuotas
SET Quota =
CASE(intQtr)
when 1 the @Qtr1
when 2 then @Qtr2
when 3 then @Qtr3
when 4 then @Qtr4
else Quota --Dont change data
END
WHERE (RepID = @repid)
AND intYear = @intyear


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

mxfrail
Yak Posting Veteran

84 Posts

Posted - 2009-05-13 : 13:04:04
Perfect!

Thanks a bunch.
Go to Top of Page
   

- Advertisement -