Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IF Update SQL Command

Posted on 2013-06-04
2
Medium Priority
?
364 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 1320 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

886 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