Solved

IF Update SQL Command

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In this article I will describe the Detach & Attach 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.
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

776 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