About 304,000 results
Open links in new tab
  1. SQL Server - Create a copy of a database table and place it in the …

    Mar 15, 2013 · Right-click on the table that you want to duplicate. Select Script Table as -> Create to -> New Query Editor Window. This will generate a script to recreate the table in a new query window. Change the table name and relative keys & constraints in the script. Execute the script. Then for copying the data run this below script:

  2. Duplicating a TABLE using Microsoft SQL Server Management

    Feb 23, 2020 · One way to copy the table structure (including default values) but NOT the actual table values is the copy / paste solution that is documented here. It works for Management Studio 2005 upwards. You just have to select all columns in the design then Edit -> Copy. Create a new table and the Edit -> Paste.

  3. sql - Copy data into another table - Stack Overflow

    Copy all columns from one table to another table: INSERT INTO table2 SELECT * FROM table1 WHERE condition; Copy only some columns from one table into another table: INSERT INTO table2 (column1, column2, column3, ...) SELECT column1, column2, column3, ... FROM table1 WHERE condition; You can duplicate or "clone" a table's contents by executing:

  4. Copy tables from one database to another in SQL Server

    Dec 8, 2013 · Copy the result and paste into query window to represent your table column names and even this will exclude the identity column as well: select (name + ',') as TableColumns from sys.columns where object_id = object_id('YourTableName') and is_identity = 0 Remember the script to copy rows will work if the databases belongs to the same location.

  5. sql - Copy table structure into new table - Stack Overflow

    Aug 3, 2009 · pg_dump dbname -s -t table_to_clone > /tmp/temp.sql Than sed or vim of the file to change the table name and related stuff. Often is enough to replace table_to_clone with table_new_name. At creation, I usually prefix with table name indexes and triggers, so at this point I have nothing more to do. Now, from psql: begin work; \i /tmp/temp.sql

  6. sql - Fastest way to copy a table in mysql? - Stack Overflow

    CREATE TABLE copy LIKE original; ALTER TABLE copy DISABLE KEYS; INSERT INTO copy SELECT * FROM original; ALTER TABLE copy ENABLE KEYS; You want to disable your keys for your database load and then recreate the keys at the end. Similarly, for InnoDB: SET unique_checks=0; SET foreign_key_checks=0; ..insert sql code here..

  7. mysql - SQL Command for copying table - Stack Overflow

    Nov 29, 2008 · What is the SQL command to copy a table from one database to another database? I am using MySQL and I have two databases x and y. Suppose I have a table in x called a and I need to copy that table to y database. Sorry if the question is too novice. Thanks.

  8. sql - How to copy a row and insert in same table with a …

    Feb 6, 2012 · IMO, the best seems to use sql statements only to copy that row, while at the same time only referencing the columns you must and want to change.

  9. t sql - Copying a table (and all of its data) from one server to ...

    Nov 24, 2023 · What I've used a lot is native SQL Server Import and Export Wizard. In SSMS's Object Explorer -> Source SQL Server -> Right click database -> Tasks -> Export Data. Choose a Data Source: Microsoft OLE DB Provider for SQL Server. Server Name: source server. Choose a Destination: Microsoft OLE DB Provider for SQL Server. Server Name: destination ...

  10. sql server - How do you copy a record in a SQL table but swap out …

    The source table and destination table are the same and the primary key is a uniqueidentifier (guid). When I try this: insert into MyTable select * from MyTable where uniqueId = @Id; I obviously get a primary key constraint violation, since I'm attempting to copy over the primary key. Actually, I don't want to copy over the primary key at all.