Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver,microsoft.public.sqlserver.programming Subject: Re: SSE 2008: Trigger: Modifying Data to be Written Date: Sun, 10 Apr 2011 21:33:33 +0200 Organization: Erland Sommarskog Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="DD6dU+BfJNjsjSP4/K/V7w"; logging-data="1999"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182cjrkEtJ4X5PePgtfWNBn" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:q1MrjluNmdh1BnRCcg21O2XUE9E= Xref: x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:158 Bob Barrows (reb01501@NOSPAMyahoo.com) writes: > Gene Wirchenko wrote: >>> 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 >> > > You consider this to be a good idea? Despite the number of experts in the > field that advise against using selstar (select *)? I won't repeat that > advice here: it's very easily found. I will say that I have never seen an > expert recommend its use. As I indicated in my reply to Gene, I think he has a point here. But as I said, there are couple of situations where it will not work. And I forgot quite an important situation: UPDATE statements. Most likely, Gene would like to use his INSTEAD OF trigger for updates as well, and you cannot do UPDATE tbl SET CORRESPONDING as in Cobol. So for updates he would have to list all columns. ...unless he first deletes the rows to be updated and the insert like above. -- 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