Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - updating multiple records
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

updating multiple records

 Post Reply Post Reply
Author
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Topic: updating multiple records
    Posted: 23 October 2003 at 12:27pm

anyone know of a good article on an efficient way to update multiple records at a time in a db?

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 23 October 2003 at 6:03pm
Access or MS SQL?

Lead me not into temptation... I know the short cut, follow me.
Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 23 October 2003 at 8:12pm
access for now. but i want to know how to do this in sql db's also
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 24 October 2003 at 12:39am

Can't recall seeing it done in Access, although I believe I saw something about using a data adapter with a repeater against Access in .net.

Most SQL DB's have a "ROWSET" concept that you can use either within a transaction or as simple lock and load. The big issue is figuring out how you want to handle it if one of the record updates fails but the rest go through.

I might have some UPDATE QUERY ms sql code that I used as a stored proc to do bulk changes on groups of records. Not quite the same thing, but I'll try to dig it out this weekend. I've also got something that passes an XML stream into an SQL parameter used by update query, uses openxml to turn it into a set, then processes the set; if that would be more useful to you.

BTW... The rowset stuff is pretty straight forward but uses cursors so you'll see a perfomance penalty. DBA's will declare that your mother was a hampster and your father smelt of elderberries!



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 24 October 2003 at 6:49am

thanks for the input,

right now the db i need to do this with is in access. there has to be a way to do it. maybe i can take all of the values with their individual id numbers and loop an update using one id at a time?!?

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 26 October 2003 at 6:06pm

What types of updates do you need to do?

To update the same fields in multiple records at once just add a WHERE clause to your update statement.

If you want to make *different* types of changes to multiple records then there's no way around applying a different UPDATE statement to each record.. how else would the database know what changes to make to each?

To apply multiple UPDATE statements, you can place them all in a stored proc and/or wrap them in a transaction and loop through them in your ASP code.

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.