TRigger no fire for Geography type

Dear all,

I have an sql table define as below :

CREATE TABLE [dbo].[PropertyGeoLocalisation](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[PropertyId] [int] NOT NULL,
	[Longitude] [float] NULL,
	[Latitude] [float] NULL,
	[Easting] [int] NULL,
	[Northing] [int] NULL,
	[Bing_Longitude] [float] NULL,
	[Bing_Latitude] [float] NULL,
	[CenterPoint] [geography] NULL,
 CONSTRAINT [PK_PropertyGeoLocalisation] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[PropertyGeoLocalisation]  WITH CHECK ADD  CONSTRAINT [FK_PropertyGeoLocalisation_Vebra_PropertyDetails] FOREIGN KEY([PropertyId])
REFERENCES [dbo].[Vebra_PropertyDetails] ([Id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[PropertyGeoLocalisation] CHECK CONSTRAINT [FK_PropertyGeoLocalisation_Vebra_PropertyDetails]
GO

Then I have a trigger which should calculate the CenterPoint field based on the following :

ALTER TRIGGER [dbo].[SetGeographyCenterPoint]
   ON  [dbo].[PropertyGeoLocalisation] 
   AFTER INSERT,UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
     UPDATE [RealEstateAgent].[dbo].[PropertyGeoLocalisation]
     SET [CenterPoint] = GEOGRAPHY::STGeomFromText('POINT('+Str([Longitude], 10, 5)+' ' +Str([Latitude],10,5)+')', 4326)

END

When I insert an item manually in my table, the trigger seems to not fire and update the column.

I am using SQL server 2012, any idea what could be wrong ?
Under SQL server 2008 it was working fine

Thanks for tips

regards

August 22nd, 2015 1:48pm

Works under 2014 and 2014 with 2012 compatibility level.

Is the trigger disabled?

Try this script:

USE RealEstateAgent
go

select Name, case when is_disabled = 0 then 'Enabled' else 'Disabled' end
from sys.triggers 
where name = 'SetGeographyCenterPoint'

Free Windows Admin Tool Kit Click here and download it now
August 22nd, 2015 3:51pm

I have try what you suggest with no luck.

When I edit one a the field directly in the table, the CenterPoint field remains null.

Any idea ?

What do you mean by "Works under 2014 and 2014 with 2012 compatibility level."

regards

August 23rd, 2015 3:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics