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 8379249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:07:38+00:00 2026-06-09T16:07:38+00:00

I have a column1 that currently matches everything in another column2 in that same

  • 0

I have a column1 that currently matches everything in another column2 in that same table. I now need the column1 to automatically update when I add a new row and fill in column2. This is in SQL.

I was thinking

ALTER TABLE dbo.Table
alter column column1 as column2

might work, but it appears not.

Is it possible to do this with something along the lines of an alter statement (ie. without a trigger)?

  • 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-09T16:07:40+00:00Added an answer on June 9, 2026 at 4:07 pm

    You can use a TRIGGER to automatically update Column2 whenever Column1 changes:

    --My SQL Server isn't up to par, there's probably a better way to do this
    CREATE TRIGGER MyTrigger
    ON Table
    AFTER UPDATE
    AS
        UPDATE Table
        SET Column2 = Column1
        WHERE Id IN (SELECT DISTINCT Id FROM Inserted)
    

    You can also make Column2 a computed column:

    ALTER TABLE Table
      ADD Column2 AS (Column1)
    

    If you always want the two to be in sync, I’d suggest just removing your existing column and added in a new computed column with the same name.

    A third way would be to create a VIEW that simply exposes Column1 twice:

    CREATE VIEW MyView AS
      SELECT Column1, Column1 as Column2 FROM Table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a table with an id column that is being autoincremented and
Currently I have a User table that has a toys_owned column that is an
I have a query that looks like SELECT P.Column1, P.Column2, P.Column3, ... ( SELECT
I have a table that contains common entries in two columns. For Example: Column1
Currently I have an address column that is an embedded document in my users
I currently have a varchar(255) column that stores the path to a small image
I currently have a Postgres 8.4 database that contains a varchar(10000) column. I'd like
I have a rowset that looks like this: defaultdict(<type 'dict'>, { u'row1': {u'column1': 33,
Currently I have a SQL server column of type nvarchar(max) which has text that
I have been trying to create a regular expressions pattern that matches any reference

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.