Solved

IF Update SQL Command

Posted on 2013-06-04
2
319 Views
Last Modified: 2013-06-04
I have the below Trigger to update a Date stamp column with any change that happens to this record.
Problem is we want it to only time stamp when a change is done to the Geometry field.
How would i modify it? I have used and IF UPDATE Command in another trigger. Would that be an option?


   AFTER INSERT, UPDATE, delete
AS 
BEGIN

declare @NewId int =  (select Parcel_ID from Inserted) 
		SET NOCOUNT ON;
	Update Parcel
		   set dbo.Parcel.GIS_lastUpdate_Date = CURRENT_TIMESTAMP
	   where Parcel_ID =  @NewId

Open in new window


I would like to say
If (geometry) is updated then
Update Parcel
               set dbo.Parcel.GIS_lastUpdate_Date = CURRENT_TIMESTAMP
         where Parcel_ID =  @NewId

I'm just not sure the syntax.
Thanks
0
Comment
Question by:PtboGiser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
yawkey13 earned 330 total points
ID: 39219931
declare @NewId int =  (select Parcel_ID from Inserted)
SET NOCOUNT ON;
IF ( UPDATE(geometry) )
BEGIN
      Update Parcel
               set dbo.Parcel.GIS_lastUpdate_Date = CURRENT_TIMESTAMP
         where Parcel_ID =  @NewId
END
0
 

Author Comment

by:PtboGiser
ID: 39219962
ok Thanks i was close sytax grabs mee most of the time!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question