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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:20:54+00:00 2026-05-10T17:20:54+00:00

Is there a clean way of cloning a record in SQL that has an

  • 0

Is there a clean way of cloning a record in SQL that has an index(auto increment). I want to clone all the fields except the index. I currently have to enumerate every field, and use that in an insert select, and I would rather not explicitly list all of the fields, as they may change over time.

  • 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. 2026-05-10T17:20:55+00:00Added an answer on May 10, 2026 at 5:20 pm

    Not unless you want to get into dynamic SQL. Since you wrote ‘clean’, I’ll assume not.

    Edit: Since he asked for a dynamic SQL example, I’ll take a stab at it. I’m not connected to any databases at the moment, so this is off the top of my head and will almost certainly need revision. But hopefully it captures the spirit of things:

    -- Get list of columns in table SELECT INTO #t EXEC sp_columns @table_name = N'TargetTable'  -- Create a comma-delimited string excluding the identity column DECLARE @cols varchar(MAX) SELECT @cols = COALESCE(@cols+',' ,'') + COLUMN_NAME FROM #t WHERE COLUMN_NAME <> 'id'  -- Construct dynamic SQL statement DECLARE @sql varchar(MAX) SET @sql = 'INSERT INTO TargetTable (' + @cols + ') ' +     'SELECT ' + @cols + ' FROM TargetTable WHERE SomeCondition'  PRINT @sql -- for debugging EXEC(@sql) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer MinGW doesn't have as many licensing restrictions as Cygwin, but… May 11, 2026 at 12:42 pm
  • added an answer In the project properties in the IDE, there is an… May 11, 2026 at 12:42 pm
  • added an answer #include <iostream> #include <ostream> #include <string> struct my_struct { int… May 11, 2026 at 12:42 pm

Related Questions

Is there a clean and OS independent way to determine the local machine's IP
Is there a way to force the flash garbage collector to clean up freed
Is there a way clear or reset the outputcache for an entire website without
Is there a clean, preferably standard method of trimming leading and trailing whitespace from
I'm working with some code (not mine I hasten to add, I don't trust
What is a nice way to end an interview that is clearly going badly?
I'm trying to come up with a clean way of sorting a set of
One of the really nice things about python is the simplicity with which you

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.