Solved

IF Update SQL Command

Posted on 2013-06-04
2
309 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
Comment Utility
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
Comment Utility
ok Thanks i was close sytax grabs mee most of the time!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL 2012 Syntax Error 5 22
SQL Select Prior Ship Date Data 2 28
Creating Alerts in sql sever 2 13
SQL Maintenance Plan 3 13
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

771 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

11 Experts available now in Live!

Get 1:1 Help Now