如何通过外键访问表的列?

时间:2017-03-28 17:42:33

标签: sql-server

我是SQL服务器的新手,遇到此触发器代码时出现问题。你能否告诉我这一行有什么问题:set NazivFirme=(select NazivFirme from inserted) ...这是我收到错误的地方。

USE [BazaPreduzece]
    GO
    /****** Object:  Trigger [dbo].[promenaNazivaFirme]    Script Date: 2017-03-28 5:29:47 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER trigger [dbo].[promenaNazivaFirme]
    on [dbo].[Firma]
    AFTER UPDATE
    as
    declare @FirmaID int
    select @FirmaID=FirmaID from inserted
    if update (NazivFirme)
    begin
    alter table Vlasnik disable trigger zabranaAzuriranjaNazivaFirme
    update [dbo].[Vlasnik]
    set NazivFirme=(select NazivFirme from inserted)
    where FirmaID=@FirmaID
    alter table Vlasnik enable trigger zabranaAzuriranjaNazivaFirme
    end

1 个答案:

答案 0 :(得分:0)