Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #734
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Erland Sommarskog <esquel@sommarskog.se> |
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: trying to replace multiple update statements with one update |
| Date | Tue, 04 Oct 2011 23:14:59 +0200 |
| Organization | Erland Sommarskog |
| Lines | 30 |
| Message-ID | <Xns9F74EC8288738Yazorman@127.0.0.1> (permalink) |
| References | <a1a10e66-2ba9-4940-b933-b02887254a04@t16g2000yqm.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx04.eternal-september.org; posting-host="nBFDv6s1VJQDuF1w6hpX2A"; logging-data="12192"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CAgnaJaisF7wc/iwW48ft" |
| User-Agent | Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) |
| Cancel-Lock | sha1:dp7w5CtD1KindeR5raNJiH/kPIw= |
| Xref | x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:734 |
Show key headers only | View raw
migurus (migurus@yahoo.com) writes: > SQL 2005, there is a table with some 20,000 rows updated quite > frequently, estimates are 2000 updates per minute. Many updates affect > several records at once, so each update touches approximately 10 - 15 > records. > > I am trying to come up with solution that avoids multiple updates with > one update, thinking that it is less load on the db locking etc... The > idea is for the app to declare a variable type of table, populate it > with key - value pairs and then issue one update statement that will > join the in memory table with the table. Sounds like an excellent idea! The only hickup is that SQL 2005 does not support table-valued parameters; you need SQL 2008 for that. However, rather than passing a TVP, you can pass the values in an XML document, and then update the table from that document. See http://www.sommarskog.se/arrays-in-sql-2005.html#XML for an introduction. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
trying to replace multiple update statements with one update migurus <migurus@yahoo.com> - 2011-10-03 18:11 -0700
Re: trying to replace multiple update statements with one update Erland Sommarskog <esquel@sommarskog.se> - 2011-10-04 23:14 +0200
Re: trying to replace multiple update statements with one update --CELKO-- <jcelko212@earthlink.net> - 2011-10-05 09:21 -0700
Re: trying to replace multiple update statements with one update Erland Sommarskog <esquel@sommarskog.se> - 2011-10-05 23:44 +0200
csiph-web