Solved

IF Update SQL Command

Posted on 2013-06-04
2
312 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
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
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…

937 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now