March 24, 2011 at 3:35 am
will a trigger will fire irrespective of updating the same value.
scenario :- i m having a table.
CREATE TABLE [dbo].[TestProfile](
[MemberID] [bigint] IDENTITY(1,1) NOT NULL,
[FirstName] [varchar](50) NOT NULL,
[LastName] [varchar](50) NULL,
[Company] [varchar](100) NULL,
[Email] [varchar](255) NOT NULL,
[IsActive] [bit] NOT NULL,
[LastModifiedDateTime] [datetime] NOT NULL,
[WhatHappened] [varchar](255) NULL,
CONSTRAINT [PK_TestProfile] PRIMARY KEY CLUSTERED
(
[MemberID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
sample data
INSERT INTO [dbo].[TestProfile]([MemberID], [FirstName], [LastName], [Company], [Email], [IsActive], [LastModifiedDateTime], [WhatHappened])
SELECT 1, N'Shyam', N'Tumati', N'Starmark', N'anil.tumati@starmarksv.com', 1, '20110101 00:00:00.000', N'nothing'
i am having a trigger on this .
now i am updating any filed with the same value as it exists like
update testprofile set firstname='Shyam' where memberid=1
In this case the trigger will fire or not?
and if i want to restrict to fire the trigger what i have to do??
any Suggestion is welcome
March 24, 2011 at 3:51 am
A trigger on update will fire regardless of whether the update is actually making a change.
You cannot prevent the trigger firing, but you can change the logic of your trigger to only perform it's action if data has actually changed (by comparing values in the Inserted and Deleted tables)
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply