Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8388425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:28:13+00:00 2026-06-09T18:28:13+00:00

I have 2 tables, Table-A and Table-A-History . Table-A contains current data rows. Table-A-History

  • 0

I have 2 tables, Table-A and Table-A-History.

  • Table-A contains current data rows.
  • Table-A-History contains historical data

I would like to have the most current row of my data in Table-A, and Table-A-History containing historical rows.

I can think of 2 ways to accomplish this:

  1. whenever a new data row is available, move the current row from Table-A to Table-A-History and update the Table-A row with the latest data (via insert into select or select into table)

    or

  2. whenever a new data row is available, update Table-A‘s row and insert a new row into Table-A-History.

In regards to performance is method 1 or 2 better? Is there a better different way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:28:15+00:00Added an answer on June 9, 2026 at 6:28 pm

    Logging changes is something I’ve generally done using triggers on a base table to record changes in a log table. The log table has additional columns to record the database user, action and date/time.

    create trigger Table-A_LogDelete on dbo.Table-A
      for delete
    as
      declare @Now as DateTime = GetDate()
      set nocount on
      insert into Table-A-History
        select SUser_SName(), 'delete-deleted', @Now, *
          from deleted
    go
    exec sp_settriggerorder @triggername = 'Table-A_LogDelete', @order = 'last', @stmttype = 'delete'
    go
    create trigger Table-A_LogInsert on dbo.Table-A
      for insert
    as
      declare @Now as DateTime = GetDate()
      set nocount on
      insert into Table-A-History
        select SUser_SName(), 'insert-inserted', @Now, *
          from inserted
    go
    exec sp_settriggerorder @triggername = 'Table-A_LogInsert', @order = 'last', @stmttype = 'insert'
    go
    create trigger Table-A_LogUpdate on dbo.Table-A
      for update
    as
      declare @Now as DateTime = GetDate()
      set nocount on
      insert into Table-A-History
        select SUser_SName(), 'update-deleted', @Now, *
          from deleted
      insert into Table-A-History
        select SUser_SName(), 'update-inserted', @Now, *
          from inserted
    go
    exec sp_settriggerorder @triggername = 'Table-A_LogUpdate', @order = 'last', @stmttype = 'update'
    

    Logging triggers should always be set to fire last. Otherwise, a subsequent trigger may rollback the original transaction, but the log table will have already been updated. This is a confusing state of affairs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a table which can contains data like this: id name
I have two tables, songs and history. The songs table looks like: ID |
I have 2 tables product and history product table: id name type price location
I have a history table like below CREATE TABLE [dbo].[t_PettyCash_History] ( [TableName] [varchar] (500)
I have data in a table in following manner tablename : history page_url verified
I have two Tables: Table 1: Questions : QuestionId NUMERIC Title TEXT Test Data
I have a table that contains a history of costs by location. These are
I have a child table that contains the history of statuses for the particular
I have two tables. First one: create table history ( id integer primary key,
I have 2 tables, a document table and a content table. They look like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.