Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 23rd, 2006, 08:46 AM
Registered User
 
Join Date: Mar 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Triggers

What syntax would I use to display the old value & the new value of a particular field during an update statement using triggers? Thanks!

Rook

 
Old October 23rd, 2006, 09:07 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

u can display OLD values using the DELETED table.

The Deleted table stores copies of the affected rows during DELETE and UPDATE statements.

i hope it will help :)


 
Old October 24th, 2006, 07:11 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

 SELECT o.*, n.*
   FROM Deleted o,
        Inserted n
  WHERE o.pkcolumnname = n.pkcolumnname

Note that this can only be done inside a trigger because the Deleted and Inserted tables only "live" inside triggers.

--Jeff Moden





Similar Threads
Thread Thread Starter Forum Replies Last Post
triggers Hafiz Muhammad Mushtaq Oracle 5 April 9th, 2009 04:25 PM
Triggers? odezzie Classic ASP Databases 1 March 28th, 2007 06:09 PM
Triggers? prabodh_mishra Oracle 2 March 30th, 2006 05:51 AM
Triggers shahchi1 SQL Server 2000 1 November 1st, 2004 06:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.