Trigger from one Db to another

  • I have two databases that interact via a trigger. The first, A is a live database in daily use. The second, B is mostly a read-only that aggregates data from the first (and from some others).

    There is one field in the B that is updated by a trigger in A, a date-last-modified field. I keep running into permission issues with this. I have users and roles in A, with permissions on the table with the trigger, but if I don't have update permission on the table in B, updates to the table in A fail, and with an incredibly unhelpful error message:

    "The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows)." (Not true, the view includes the primary key, and I get this error when simply manually changing one character in one text field of one record.)

    Interestingly, I CAN update the table directly, but I get this weird failure when doing the update through a view, even when logged in as sa and doing the update manually in SSMSE. I found the following on the MSDN website: To retrieve data from a table or view, a user must have SELECT statement permission on the table or view. To update the content of a table or view, a user must have INSERT, DELETE, and UPDATE statement permissions on the table or view.

    This seems wrong to me. If I have update permission on the table in A, that should be the end of it. What, if anything, the table chooses to do subsequent to my update should not be an issue, and in fact, I could even argue that it's none of my business. That fact that I also need update permission on the table in B means that every time I do something to the permission structure in A, or any other database with a similar function, I have to make corresponding changes in B, or those changes may well cause applications to stop working properly.

    And why is it that I can update the table (which contains the trigger) directly, but not through the view of the table? I'll post the table and view and trigger definitions if anyone wants to see them, but I didn't want my initial post to be too cluttered.

    Is there some way around this? Something like 'execute as owner', which would chain permissions from the table and so obviate the need for fiddling permissions in both databases? Or might there be a better way to do this altogether? I'm the sole author of both databases, as well as the only programmer/developer/DBA in this entire project, so I can do absolutely anything I deem necessary, without having to clear it with anyone else.

  • Yes, post the definitions. We can't answer your question(s) when we can't see what you see.

  • Lynn Pettis (4/12/2012)


    Yes, post the definitions. We can't answer your question(s) when we can't see what you see.

    Okay, here they are.

    The trigger in A:USE [PaleoDataProPokusy]

    GO

    /****** Object: Trigger [dbo].[tr_DatumZmenyPaleontologie] Script Date: 04/12/2012 18:12:17 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    /****** Vyžaduje práva k zmene v tabulce OpenUp.dbo.PaleontologieContactPerson, jinak aplikace Paleontologie práskne. ******/

    /****** Tvrdá zkušenost, když jsem zavedl tento Trigger a vyzkoušel jen ve vlastním úctu, pak na nej zapomel, když uživatelum ******/

    /****** najednou (až príští týden) nefungovala databáze. ******/

    CREATE trigger [dbo].[tr_DatumZmenyPaleontologie]

    on [PaleoDataProPokusy].[dbo].[Podrobnosti]

    for update, insert, delete

    as

    update OpenUp.dbo.PaleontologieContactPerson

    set DatumPosledniZmeny = CURRENT_TIMESTAMP

    GO

    The table in B (OpenUp) being updated by the trigger:USE [OpenUp]

    GO

    /****** Object: Table [dbo].[PaleontologieContactPerson] Script Date: 04/12/2012 18:40:55 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[PaleontologieContactPerson](

    [AutoID] [bigint] IDENTITY(1,1) NOT NULL,

    [DummyJoinFieldAlwaysZero] [int] NOT NULL,

    [Name] [varchar](255) NOT NULL,

    [Email] [varchar](255) NOT NULL,

    [Address] [varchar](255) NOT NULL,

    [Phone] [varchar](255) NOT NULL,

    [PopisSbirky] [varchar](255) NOT NULL,

    [DatumPosledniZmeny] [smalldatetime] NOT NULL,

    [EuropeanaRights] [varchar](50) NOT NULL,

    [EuropeanaType] [varchar](50) NOT NULL,

    [EuropeanaURI] [varchar](50) NOT NULL,

    CONSTRAINT [PK_PaleontologieContactInfo] PRIMARY KEY CLUSTERED

    (

    [AutoID] 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

    SET ANSI_PADDING OFF

    GO

    The table in A (PaleoDataProPokusy) containing the trigger:USE [PaleoDataProPokusy]

    GO

    /****** Object: Table [dbo].[Podrobnosti] Script Date: 04/12/2012 18:42:51 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[Podrobnosti](

    [PodrobnostiAutoID] [int] IDENTITY(1,1) NOT NULL,

    [AkcesAutoID] [int] NOT NULL,

    [EvidenceLetter] [nvarchar](2) NULL,

    [EvidenceNumber] [int] NULL,

    [EvidenceExtra] [varchar](2) NULL,

    [EvidenceGroup] [int] NULL,

    [GroupAutoID] [int] NULL,

    [OrderAutoID] [int] NULL,

    [FamilyAutoID] [int] NULL,

    [GenusAutoID] [int] NULL,

    [SubGenusAutoID] [int] NULL,

    [SpeciesAutoID] [int] NULL,

    [SubSpeciesAutoID] [int] NULL,

    [SystemAutoID] [int] NULL,

    [SeriesAutoID] [int] NULL,

    [StageAutoID] [int] NULL,

    [SubStageAutoID] [int] NULL,

    [LithographicUnitAutoID] [int] NULL,

    [LithographicSubUnitAutoID] [int] NULL,

    [ZoneAutoID] [int] NULL,

    [CountryAutoID] [int] NULL,

    [DepozitarAutoID] [int] NULL,

    [PDAutoID] [int] NULL,

    [ODAutoID] [int] NULL,

    [OriginAutoID] [int] NULL,

    [TypAutoID] [int] NULL,

    [PocetKusu] [int] NULL,

    [OTHER_NO] [varchar](255) NULL,

    [TvoreniZaznamuDatum] [datetime] NULL,

    [TvoreniZaznamuClovek] [varchar](50) NULL,

    [ZapisEvidenceDatum] [datetime] NULL,

    [ZapisEvidenceClovek] [varchar](50) NULL,

    [Inventarizace] [varchar](1000) NULL,

    [Poznamka] [varchar](4000) NULL,

    [Description] [varchar](4000) NULL,

    [RockType] [varchar](255) NULL,

    [Preserv] [varchar](255) NULL,

    [UlozisteDocasne] [varchar](255) NULL,

    [Original] [varchar](1000) NULL,

    [Authors] [varchar](255) NULL,

    [Lokalita] [varchar](255) NULL,

    [IDNeDruheEvidence] [varchar](255) NULL,

    [NepublikovatYN] [bit] NOT NULL,

    CONSTRAINT [PK_Podrobnosti] PRIMARY KEY NONCLUSTERED

    (

    [PodrobnostiAutoID] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    SET ANSI_PADDING OFF

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_Akces] FOREIGN KEY([AkcesAutoID])

    REFERENCES [dbo].[Akces] ([AkcesAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_Akces]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_EvidenceLetters] FOREIGN KEY([EvidenceLetter])

    REFERENCES [dbo].[EvidenceLetters] ([EvidenceLetter])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_EvidenceLetters]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfCountrys] FOREIGN KEY([CountryAutoID])

    REFERENCES [dbo].[TableOfCountrys] ([CountryAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfCountrys]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfDepozitars] FOREIGN KEY([DepozitarAutoID])

    REFERENCES [dbo].[TableOfDepozitars] ([DepozitarAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfDepozitars]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfFamilys] FOREIGN KEY([FamilyAutoID])

    REFERENCES [dbo].[TableOfFamilys] ([FamilyAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfFamilys]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfGenuss] FOREIGN KEY([GenusAutoID])

    REFERENCES [dbo].[TableOfGenuss] ([GenusAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfGenuss]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfGroups] FOREIGN KEY([GroupAutoID])

    REFERENCES [dbo].[TableOfGroups] ([GroupAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfGroups]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfLithographicSubUnits] FOREIGN KEY([LithographicSubUnitAutoID])

    REFERENCES [dbo].[TableOfLithographicSubUnits] ([LithographicSubUnitAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfLithographicSubUnits]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfLithographicUnits] FOREIGN KEY([LithographicUnitAutoID])

    REFERENCES [dbo].[TableOfLithographicUnits] ([LithographicUnitAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfLithographicUnits]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfODs] FOREIGN KEY([ODAutoID])

    REFERENCES [dbo].[TableOfODs] ([ODAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfODs]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfOrders] FOREIGN KEY([OrderAutoID])

    REFERENCES [dbo].[TableOfOrders] ([OrderAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfOrders]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfOrigins] FOREIGN KEY([OriginAutoID])

    REFERENCES [dbo].[TableOfOrigins] ([OriginAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfOrigins]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfPDs] FOREIGN KEY([PDAutoID])

    REFERENCES [dbo].[TableOfPDs] ([PDAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfPDs]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfSeriess] FOREIGN KEY([SeriesAutoID])

    REFERENCES [dbo].[TableOfSeriess] ([SeriesAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfSeriess]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfSpeciess] FOREIGN KEY([SpeciesAutoID])

    REFERENCES [dbo].[TableOfSpeciess] ([SpeciesAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfSpeciess]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfStages] FOREIGN KEY([StageAutoID])

    REFERENCES [dbo].[TableOfStages] ([StageAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfStages]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfSubGenuss] FOREIGN KEY([SubGenusAutoID])

    REFERENCES [dbo].[TableOfSubGenuss] ([SubGenusAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfSubGenuss]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfSubSpeciess] FOREIGN KEY([SubSpeciesAutoID])

    REFERENCES [dbo].[TableOfSubSpeciess] ([SubSpeciesAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfSubSpeciess]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfSubStages] FOREIGN KEY([SubStageAutoID])

    REFERENCES [dbo].[TableOfSubStages] ([SubStageAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfSubStages]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfSystems] FOREIGN KEY([SystemAutoID])

    REFERENCES [dbo].[TableOfSystems] ([SystemAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfSystems]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfTyps] FOREIGN KEY([TypAutoID])

    REFERENCES [dbo].[TableOfTyps] ([TypAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfTyps]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [FK_Podrobnosti_TableOfZones] FOREIGN KEY([ZoneAutoID])

    REFERENCES [dbo].[TableOfZones] ([ZoneAutoID])

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [FK_Podrobnosti_TableOfZones]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [CK_Podrobnosti_DrEvidence] CHECK (([EvidenceLetter] IS NULL AND [EvidenceNumber] IS NULL AND [EvidenceExtra] IS NULL AND [EvidenceGroup] IS NULL OR (len([EvidenceLetter])=(1) OR len([EvidenceLetter])=(2) AND ascii(right([EvidenceLetter],(1)))<>(115) AND [EvidenceGroup]=(0) OR len([EvidenceLetter])=(2) AND ascii(right([EvidenceLetter],(1)))=(115) AND [EvidenceGroup]<(0)) AND [EvidenceNumber] IS NOT NULL AND [EvidenceNumber]>(0) AND [EvidenceExtra] IS NOT NULL))

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [CK_Podrobnosti_DrEvidence]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [CK_Podrobnosti_EvidenceExtra] CHECK ((len([EvidenceExtra])=(0) OR len([EvidenceExtra])=(1) AND ([EvidenceExtra]>='a' AND [EvidenceExtra]<='z' OR [EvidenceExtra]='+' OR [EvidenceExtra]='-') OR len([EvidenceExtra])=(2) AND (left([EvidenceExtra],(1))>='a' AND left([EvidenceExtra],(1))<='z' AND right([EvidenceExtra],(1))>='a' AND right([EvidenceExtra],(1))<='z')))

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [CK_Podrobnosti_EvidenceExtra]

    GO

    ALTER TABLE [dbo].[Podrobnosti] WITH CHECK ADD CONSTRAINT [CK_Podrobnosti_EvidenceGroup] CHECK (([EvidenceGroup]<=(0)))

    GO

    ALTER TABLE [dbo].[Podrobnosti] CHECK CONSTRAINT [CK_Podrobnosti_EvidenceGroup]

    GO

    ALTER TABLE [dbo].[Podrobnosti] ADD CONSTRAINT [DF_Podrobnosti_Nepublikovat] DEFAULT ((0)) FOR [NepublikovatYN]

    GO

    The view in A, which throws an error when attempting an update:USE [PaleoDataProPokusy]

    GO

    /****** Object: View [dbo].[vwPodrobnosti] Script Date: 04/12/2012 18:43:48 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE VIEW [dbo].[vwPodrobnosti]

    AS

    SELECT PodrobnostiAutoID, AkcesAutoID, EvidenceLetter, EvidenceNumber, EvidenceExtra, EvidenceGroup, GroupAutoID, OrderAutoID, FamilyAutoID,

    GenusAutoID, SubGenusAutoID, SpeciesAutoID, SubSpeciesAutoID, SystemAutoID, SeriesAutoID, StageAutoID, SubStageAutoID, LithographicUnitAutoID,

    LithographicSubUnitAutoID, ZoneAutoID, CountryAutoID, DepozitarAutoID, PDAutoID, ODAutoID, OriginAutoID, PocetKusu, OTHER_NO,

    TvoreniZaznamuDatum, TvoreniZaznamuClovek, ZapisEvidenceDatum, ZapisEvidenceClovek, Inventarizace, Poznamka, Description, RockType,

    Preserv, UlozisteDocasne, Original, Authors, Lokalita, IDNeDruheEvidence, NepublikovatYN, TypAutoID

    FROM dbo.Podrobnosti

    GO

    Is this enough, or do I need to post other things as well? If so, what? All the logins and roles?

    BTW, it definitely is the trigger that's the problem. If I open the problem view in SSMSE and attempt to change a field, I have success or lack thereof depending exactly on whether I drop or add the trigger, without even reopening the view for edit. Trigger added, updates fail. Trigger dropped, updates work.

  • Any error messages? If so, the complete error message(s) would be helpful.

  • Lynn Pettis (4/12/2012)


    Any error messages? If so, the complete error message(s) would be helpful.

    Yes, that was in my initial post:

    "The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows)." (Not true, the view includes the primary key, and I get this error when simply manually changing one character in one text field of one record.)

    Here's the entire dialog box:

    -------------------------------------------------------------

    Microsoft SQL Server Management Studio

    No row was updated.

    The data in row 8 was not committed.

    Error Source: Microsoft.SqlServer.Management.DataTools.

    Error Message: The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows).

    Correct the errors and retry or press ESC to cancel the change(s).

    OK

    -------------------------------------------------------------

  • Any triggers on the other table? If so, could you post it also?

  • Lynn Pettis (4/12/2012)


    Any triggers on the other table? If so, could you post it also?

    No, the only trigger is the one I posted. It updates the DateLastChanged (DatumPosledniZmeny) field in the B (OpenUp) database whenever something happens in that one table, Podrobnosti, in the A database. There are no other triggers anywhere.

  • the trigger has no WHERE statement, and never references inserted or joins to the remote table...does that remote table only have one row?

    is there a realtionship between teh local table and the remote table that needs to be done, like this?

    that is what i would expect in a trigger:

    CREATE trigger [dbo].[tr_DatumZmenyPaleontologie]

    on [PaleoDataProPokusy].[dbo].[Podrobnosti]

    for update, insert, delete

    as

    update OpenUp.dbo.PaleontologieContactPerson

    set DatumPosledniZmeny = CURRENT_TIMESTAMP

    FROM INSERTED

    WHERE OpenUp.dbo.PaleontologieContactPerson.ID =

    INSERTED.ID

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (4/12/2012)


    the trigger has no WHERE statement, and never references inserted or joins to the remote table...does that remote table only have one row?

    is there a realtionship between teh local table and the remote table that needs to be done, like this?

    that is what i would expect in a trigger:

    CREATE trigger [dbo].[tr_DatumZmenyPaleontologie]

    on [PaleoDataProPokusy].[dbo].[Podrobnosti]

    for update, insert, delete

    as

    update OpenUp.dbo.PaleontologieContactPerson

    set DatumPosledniZmeny = CURRENT_TIMESTAMP

    FROM INSERTED

    WHERE OpenUp.dbo.PaleontologieContactPerson.ID =

    INSERTED.ID

    Great catch. I totally missed that one.

  • Lowell (4/12/2012)


    the trigger has no WHERE statement, and never references inserted or joins to the remote table...does that remote table only have one row?

    Yes, sorry, I should have noted that. It is a one-row table, with only some (fairly) static information like my name, address, email, the institution's name, email and so on, for contact information. There is and always will be exactly one row, and in that row, I want this trigger to note when the contents of the triggered table change.

    is there a realtionship between teh local table and the remote table that needs to be done, like this?

    No, there is no relationship. It's kind of like the date last changed property of a file - has no relation to the file's contents, nor does it provide any logging history, only marks the last instant that someone played with it.

    that is what i would expect in a trigger:

    CREATE trigger [dbo].[tr_DatumZmenyPaleontologie]

    on [PaleoDataProPokusy].[dbo].[Podrobnosti]

    for update, insert, delete

    as

    update OpenUp.dbo.PaleontologieContactPerson

    set DatumPosledniZmeny = CURRENT_TIMESTAMP

    FROM INSERTED

    WHERE OpenUp.dbo.PaleontologieContactPerson.ID =

    INSERTED.ID

    If I were trying to generate a tracking history, I would indeed use some such construct, but that is not the case here. I apologize for not making that clear right off the bat.

  • Try adding SET NOCOUNT ON in the top of the trigger body.

    http://stackoverflow.com/questions/4982403/sql-server-update-trigger-not-unique-insert-issue

  • Stephanie Giovannini (4/12/2012)


    Try adding SET NOCOUNT ON in the top of the trigger body.

    http://stackoverflow.com/questions/4982403/sql-server-update-trigger-not-unique-insert-issue

    That did it (bowing and scraping in admiration) - of course, now I feel like an idiot, since I routinely visit StackOverflow myself. Many thanks.

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply