Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Dear All,I have a table which i am updating from back end.As datemodifed column is having a default constraint when user inserts data from front end application it will get insert latest value.But when i am updating the specific column its not getting updated.So i am planning to create the trigger on this table to get updated for the same table.My update script like this:update HCP set isactive = 1, activeindicator = 1, inactivereason_id = null,DateModified=getdate()where (isactive <> 1 or activeindicator <> 1) and legacyID in (select DMID from Atlantis_Staging_Doctor where Rectype <> 'D')table schema:Column_name TypeID intDateModified datetimeLegacyID nvarcharCategory_ID intTitle_ID intNameGiven nvarcharNameMiddle nvarcharNameFamily nvarcharNameLocale_ID intPosition_ID intGender_ID intActiveIndicator intHCPIDNumber nvarcharInactiveReason_ID intSpecialty_ID intSubSpecialty_ID intResearchInterest_ID intOtherInterest_ID intHitListIndicator tinyintMobile nvarcharPagerNumber nvarcharEmail nvarcharEmail2 nvarcharEmailPersonalIndicator intPreCallObjective_ID intPreCallNote nvarcharOptionalField1 nvarcharOptionalField2 nvarcharOptionalField3 nvarcharOptionalField4 nvarcharOptionalField5 nvarcharOptionalField6 nvarcharOptionalField7 nvarcharOptionalField8 nvarcharOptionalField9 nvarcharOptionalField10 nvarcharCountry_ID intIsActive bitAU_Conv_HCP_ID intOtherInterest nvarcharMailingAddress_ID intClassification_ID intLastCallDate datetimeLastCallNote nvarcharSession_ID intNo_Mail tinyintNamePreferred nvarcharTrialInterestIndicator intDuplicateHCP_ID intNotes nvarcharThanks,Gangadhara MSSQL Developer and DBA
Lumbago
Norsk Yak Master
3271 Posts
Posted - 2010-12-21 : 07:26:16
[code]CREATE TRIGGER [trgHCPUpdate] ON HCP FOR UPDATEAS SET NOCOUNT ONUPDATE a SET a.DateModified = GETDATE()FROM HCP a INNER JOIN inserted b ON a.ID = b.ID[/code]- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com
MageshkumarM
Yak Posting Veteran
61 Posts
Posted - 2010-12-22 : 04:51:52
CREATE TRIGGER [hcpUpdate] ON HCP FOR UPDATEAS SET NOCOUNT ONUPDATE a SET a.DateModified = GETDATE()FROM HCP a INNER JOIN inserted b ON a.ID = b.IDMageshkumar.M MCA
Sachin.Nand
2937 Posts
Posted - 2010-12-22 : 04:57:21
quote:Originally posted by MageshkumarM CREATE TRIGGER [hcpUpdate] ON HCP FOR UPDATEAS SET NOCOUNT ONUPDATE a SET a.DateModified = GETDATE()FROM HCP a INNER JOIN inserted b ON a.ID = b.IDMageshkumar.M MCA
How is your solution different than what Lumbago suggested except for the trigger name ?PBUH
Kristen
Test
22859 Posts
Posted - 2010-12-22 : 05:42:18
quote:Originally posted by Sachin.Nand How is your solution different than what Lumbago suggested except for the trigger name ?
The formatting has been de-normalised
Sachin.Nand
2937 Posts
Posted - 2010-12-22 : 05:48:18
quote:Originally posted by Kristen
quote:Originally posted by Sachin.Nand How is your solution different than what Lumbago suggested except for the trigger name ?
The formatting has been de-normalised
Damn how could I miss that ? Seems its time for a new pair of glasses for me...PBUH