Refresh table using Trigger

  • I do have following requirement.

    Whenever the Subscriptions table(table 1) is refreshed I need the SubsLog (table 2) to be refreshed also so they are in sync. For a given KeyCol (Column 1 in table 1) in the Subscriptions table I need to be able to retrieve all changes in KeyFulfillmentStatus(column 2 in table 1) that have occurred - hence the need for the Log table. After being refreshed both tables should be included in replication to their respective tables in DEVSQL.Replicated(Other server.Database).

    Can anyone help me with that?

  • Please post table definitions, sample data and expected results as per http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Here is the table definition.

    I have also attaches sample data for Subscription.

    Table 1 : Subscription

    Columns : KeyFullfillmentStatus, Keysub

    CREATE TABLE [dbo].[Subscriptions](

    [KeySub] [int] NOT NULL,

    [KeyProduct] [char](3) NOT NULL,

    [Expiration] [smalldatetime] NOT NULL,

    [SubKey] [char](10) NOT NULL,

    [KeyPerson] [int] NULL,

    [KeyInstn] [int] NULL,

    [CoKey] [char](10) NULL,

    [KeyOnlineAccount] [int] NULL,

    [KeyFulfillmentStatus] [char](1) NOT NULL,

    [KeyPaymentStatus] [char](1) NOT NULL)

    Table 2: Sublog

    CREATE TABLE [dbo].[Sublog](

    [KeyLogGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL,

    [KeySub] [int] NOT NULL,

    [WhenModified] [datetime] NOT NULL,

    [KeyItem] [int] NOT NULL,

    [UserName] [varchar](256) NOT NULL,

    [UpdOperation] [tinyint] NOT NULL,

    [NewValue] [varchar](255) NULL,

    [OldValue] [varchar](255) NULL,

    [AppName] [varchar](255) NULL)

    Server.Databse: DevSQL..Replicated

Viewing 3 posts - 1 through 3 (of 3 total)

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