Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,224 of 19,505    |
|    Erland Sommarskog to Gene Wirchenko    |
|    Re: SSE 2008: Trigger: Modifying Data to    |
|    10 Apr 11 14:48:15    |
      XPost: microsoft.public.sqlserver.programming       From: esquel@sommarskog.se              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              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca