Monday, March 26, 2012

How do I know if a column is updated?

Hi,
In SQL Server 2000, how do I know that a paricular column in a Table row is
updated?
e.g., in Customer(ID, Name, SSN, DoB, Address),
the (0001, John, 123456789,1980/01/02,'1234 Main Street'),
where the '1234 Main Street' is updated.
Thanks for help.
JasonThis is a multi-part message in MIME format.
--020706030805090103030202
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
You could respond to the change in an UPDATE trigger. In the trigger
you can use the IF UPDATE()
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_08_7377.asp>
clause to determine if any particular column has been changed. For example,
CREATE TRIGGER MyUpdateTrigger ON dbo.MyTable
FOR UPDATE AS
IF UPDATE(MyCol)
BEGIN
...
END
GO
where MyCol is a column in dbo.MyTable that you want to respond to
changes on.
--
*mike hodgson*
http://sqlnerd.blogspot.com
Jason Huang wrote:
>Hi,
>In SQL Server 2000, how do I know that a paricular column in a Table row is
>updated?
>e.g., in Customer(ID, Name, SSN, DoB, Address),
>the (0001, John, 123456789,1980/01/02,'1234 Main Street'),
>where the '1234 Main Street' is updated.
>Thanks for help.
>
>Jason
>
>
--020706030805090103030202
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>You could respond to the change in an UPDATE trigger. In the
trigger you can use the <a
href="http://links.10026.com/?link=IF">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_08_7377.asp">IF
UPDATE()</a> clause to determine if any particular column has been
changed. For example,<br>
</tt>
<blockquote><tt>CREATE TRIGGER MyUpdateTrigger ON dbo.MyTable</tt><br>
<tt>FOR UPDATE AS</tt><br>
<tt> IF UPDATE(MyCol)</tt><br>
<tt> BEGIN</tt><br>
<tt> ...</tt><br>
<tt> END</tt><br>
<tt>GO</tt><br>
</blockquote>
<tt>where MyCol is a column in dbo.MyTable that you want to respond to
changes on.<br>
</tt>
<div class="moz-signature">
<title></title>
<meta http-equiv="Content-Type" content="text/html; ">
<p><span lang="en-au"><font face="Tahoma" size="2">--<br>
</font></span> <b><span lang="en-au"><font face="Tahoma" size="2">mike
hodgson</font></span></b><span lang="en-au"><br>
<font face="Tahoma" size="2"><a href="http://links.10026.com/?link=http://sqlnerd.blogspot.com</a></font></span>">http://sqlnerd.blogspot.com">http://sqlnerd.blogspot.com</a></font></span>
</p>
</div>
<br>
<br>
Jason Huang wrote:
<blockquote cite="midu8m7SusVGHA.5592@.TK2MSFTNGP09.phx.gbl" type="cite">
<pre wrap="">Hi,
In SQL Server 2000, how do I know that a paricular column in a Table row is
updated?
e.g., in Customer(ID, Name, SSN, DoB, Address),
the (0001, John, 123456789,1980/01/02,'1234 Main Street'),
where the '1234 Main Street' is updated.
Thanks for help.
Jason
</pre>
</blockquote>
</body>
</html>
--020706030805090103030202--

No comments:

Post a Comment