Welcome to Sign in | Help

Re: ?

  •  05-14-2008, 8:40 PM

    Re: ?

    asta ar fi codul trigger-ului pt delete:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    USE [Eug_tests]
    GO
    /****** Object: Trigger [dbo].[DeleteCompany] Script Date: 05/14/2008 20:29:43 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author:    <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:  <Description,,>
    -- =============================================
    CREATE TRIGGER [dbo].[DeleteCompany]
    ON [dbo].[Companii] for Delete

    AS
    BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
    INSERT INTO Istorie_Op_Companii
    (id_companie, alte_date_companie, operatie)
    SELECT Id, alte_date, 'stergere' AS Expr1
    FROM Deleted
    -- Insert statements for trigger here

    END

    asta ar fi pt insert:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    USE [Eug_tests]
    GO
    /****** Object: Trigger [dbo].[InsertCompany] Script Date: 05/14/2008 20:34:52 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author:    <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:  <Description,,>
    -- =============================================
    CREATE TRIGGER [dbo].[InsertCompany]
    ON [dbo].[Companii] for Insert

    AS
    BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
    INSERT INTO Istorie_Op_Companii
    (id_companie, alte_date_companie, operatie)
    SELECT Id, alte_date, 'inserare' AS Expr1
    FROM Inserted
    -- Insert statements for trigger here

    END



    tabelele folosite:
    1. Companii

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    USE [Eug_tests]
    GO
    /****** Object: Table [dbo].[Companii] Script Date: 05/14/2008 20:30:54 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Companii](
      [Id] [int] IDENTITY(1,1) NOT NULL,
      [alte_date] [nvarchar](50) NULL,
    CONSTRAINT [PK_Companii] 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]


    2. Istorie_Op_Companii

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    USE [Eug_tests]
    GO
    /****** Object: Table [dbo].[Istorie_Op_Companii] Script Date: 05/14/2008 20:31:29 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Istorie_Op_Companii](
      [Id_istoric] [int] IDENTITY(1,1) NOT NULL,
      [operatie] [nvarchar](50) NULL,
      [id_companie] [int] NULL,
      [alte_date_companie] [nvarchar](50) NULL
    ) ON [PRIMARY]

    sper ca e de folos :)
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems