Forum Moderators: open

Message Too Old, No Replies

multiple updates with sqlServer possible?

         

topr8

1:29 pm on May 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



some aggregated/calculated data is used often on a site,

but doesn't change a lot, i want to create a table then update it daily so that i can do the update in the early hours and therefore at busy times pull the data from the daily updated table rather than calculate on the fly on each call.

i can't seem to get a multiple update to work, i want to do an update rather like using INSERT INTO, is it possible?

currently am running a query and looping through the result with asp and consiquently doing (several thousand) individual updates - (i'll prob do it with stored proc to do it when it is working as required)

this seems intensive use of the db server, any other more elegant way?

arran

1:45 pm on May 4, 2005 (gmt 0)

10+ Year Member



You could maybe use a "update set select" e.g.

UPDATE yourtable
SET column1 =
(SELECT anothercolumn
FROM anothertable
WHERE ...),
SET column2 =
(SELECT yetanothercolumn
FROM yetanothertable
WHERE ...)
FROM yourtable, anothertable,yetanothertable;

topr8

2:11 pm on May 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks that looks like a good way forward i'll play around with that.