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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:46:37+00:00 2026-06-17T10:46:37+00:00

I am using Sql Server 2005. I have this tableA with 70 columns and

  • 0

I am using Sql Server 2005. I have this tableA with 70 columns and about 5000rows. I would like to create new data(around 200 new records) for simulation purposes. Out of the 70 columns, i only want to change values of 3 columns (TERMID, OUTLET, SNUM) the rest remains. E.g

    TABLEA  
    SNO  COMPANY.......TERMID........OUTLET........SNUM.....  
     1     ABC           PP2          P1-P5         P5  
     1     ABC           PP2          P1-P5         P4  
     2     ABC           PP2          P1-P5         P4  
     1     ABC           PP2          P1-P5         P3  
     3     ABC           PP2          P1-P5         P3  

so i would like to keep all values for the new records except changing all TERMID from PP2 to PP3 and all outlet from P1-P5 to P6-P8. As for SNUM all P5 will become P8, P4 will become P7 and P3 will become P6. Meaning TABLEA will look like this after i do the insert:

      TABLEA  
    SNO  COMPANY.......TERMID........OUTLET........SNUM.....  
     1     ABC           PP2          P1-P5         P5  
     1     ABC           PP2          P1-P5         P4  
     2     ABC           PP2          P1-P5         P4  
     1     ABC           PP2          P1-P5         P3  
     3     ABC           PP2          P1-P5         P3  
     1     ABC           PP3          P6-P8         P8  
     1     ABC           PP3          P6-P8         P7  
     2     ABC           PP3          P6-P8         P7  
     1     ABC           PP3          P6-P8         P6  
     3     ABC           PP3          P6-P8         P6  

I do not want to do this manually as it will be very tedious for 200 rows. Is this possible using SQL statements?

I have tot of writing normal insert statements with subquery but i guess it will be as tedious or maybe even more to write INSERT INTO TABLEA ( COL1, COL2,…….COL70) VALUE (…..)

Any smart idea?

  • 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-17T10:46:39+00:00Added an answer on June 17, 2026 at 10:46 am

    I just reread your response, and realize you’re trying to Insert records in your current table, not create a new table.

    How about:

    SELECT * 
    INTO #NewTable 
    FROM TABLEA;
    
    UPDATE #NewTable 
    SET TERMID = 'PP3', 
        OUTLET= 'P6-P8', 
        SNUM = CASE 
                   WHEN SNUM = 'P5' THEN 'P8'
                   WHEN SNUM = 'P4' THEN 'P7'
                   WHEN SNUM = 'P3' THEN 'P6'
               END;
    
    INSERT INTO TABLEA 
    SELECT * 
    FROM #NewTable
    

    Sorry for the confusion.

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

Sidebar

Related Questions

Im using SQL Server 2005. I have a table1 with 3 columns. And table2
i have using aqua data studio to run my query from sql server 2005.
DB: SQL Server 2005 We have a table that has data in this manner:
I am using MS SQL server 2005 I have a table with 3 columns
Using SQL Server 2005 I have a query that gets child records from bundles
[using SQL Server 2005] I have a table full of users, I want to
I'm using SQL Server 2005 I have a user. We'll call him User1. He
I'm using SQL Server 2005 and have the following T-SQL statement: DECLARE @MP VARCHAR(500)
I'm using SQL Server 2005 express I have a datetime field in a table
I am using SQL Server 2005. I have a requirement to list out all

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.