Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #156
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming |
| Subject | Re: SSE 2008: Trigger: Modifying Data to be Written |
| Followup-To | comp.databases.ms-sqlserver |
| Date | 2011-04-10 14:48 +0200 |
| Organization | Erland Sommarskog |
| Message-ID | <Xns9EC396993713Yazorman@127.0.0.1> (permalink) |
| References | <ab1vp6pks4qspe0bomof4pcnibgbpu8g10@4ax.com> <ino33e$1rk$1@dont-email.me> <p16vp6545phoh2i1ag0s2apt53guue997h@4ax.com> <Xns9EC273A5FD7A3Yazorman@127.0.0.1> <s9c2q6db63sck7oq2cn3au9bmlqs2lr83m@4ax.com> |
Cross-posted to 2 groups.
Followups directed to: comp.databases.ms-sqlserver
Gene Wirchenko (genew@ocis.net) writes: > 2) I think that maintainability was covered by the code I borrowed > from. My derivative has > select * into #Inserted from Inserted > at the beginning and then at the end, writes with > insert into Accounts select * from #Inserted That should work. One of the few situations where SELECT * in production code could be defended. Unfortunately, it will not work if the table has an identity column, a timestamp column or a computed colunm. I have also experienced performance problems with using SELECT INTO in a trigger which was written to handle multi-row inserts, but the transaction at hand was a loop that did things one-by-one. I found by testing that SELECT INTO was more expensive that using CREATE TABLE #temp, which in its turn was more expensive than table variables. Then again, this was on SQL 2000, and it is possible that the temp-table caching in later versions alleviates the problem. I haven't come around to test that. -- 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 | Unroll thread
SSE 2008: Trigger: Modifying Data to be Written Gene Wirchenko <genew@ocis.net> - 2011-04-08 15:11 -0700
Re: SSE 2008: Trigger: Modifying Data to be Written "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-04-08 18:44 -0400
Re: SSE 2008: Trigger: Modifying Data to be Written Gene Wirchenko <genew@ocis.net> - 2011-04-08 16:23 -0700
Re: SSE 2008: Trigger: Modifying Data to be Written Erland Sommarskog <esquel@sommarskog.se> - 2011-04-09 11:22 +0200
Re: SSE 2008: Trigger: Modifying Data to be Written Gene Wirchenko <genew@ocis.net> - 2011-04-09 21:29 -0700
Re: SSE 2008: Trigger: Modifying Data to be Written Erland Sommarskog <esquel@sommarskog.se> - 2011-04-10 14:48 +0200
Re: SSE 2008: Trigger: Modifying Data to be Written Gene Wirchenko <genew@ocis.net> - 2011-04-11 09:46 -0700
Re: SSE 2008: Trigger: Modifying Data to be Written "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-04-10 08:54 -0400
Re: SSE 2008: Trigger: Modifying Data to be Written Erland Sommarskog <esquel@sommarskog.se> - 2011-04-10 21:33 +0200
Re: SSE 2008: Trigger: Modifying Data to be Written Gene Wirchenko <genew@ocis.net> - 2011-04-11 09:42 -0700
Re: SSE 2008: Trigger: Modifying Data to be Written "Bob Barrows" <reb01501@NOyahooSPAM.com> - 2011-04-11 14:55 -0400
Re: SSE 2008: Trigger: Modifying Data to be Written Gene Wirchenko <genew@ocis.net> - 2011-04-11 14:53 -0700
Re: SSE 2008: Trigger: Modifying Data to be Written "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-04-11 18:49 -0400
csiph-web