Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
PostgreSQL - Copy Table
Next article icon

SQL Server Copy Table

Last Updated : 24 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Copying or replicating tables is one of the crucial functions of database management systems. Copy table is a crucial option to create table data backups or to create duplicate data from a table to another table with few columns or some of the data for various purposes.

In this article, We will learn about the SQL Server Copy Table by understanding various approaches with the help of examples and so on.

SQL Server Copy Table

SQL Server provides a convenient way to copy tables within the same database. Below are the approaches that help us to copy tables in SQL Server are as follows:

  1. Using SQL Query
  2. Using SQL Server Management Studio (SSMS)

Let's set up an Environment:

Let us take an example of the 'Products' table which has the below columns and data to explain the copy table methods:

ProductsTable
Products Table

The above table named 'Products' has 16 rows of data and 6 columns namely ProductID, ProductName, SupplierID, CategoryID, Unit, Price.

1. Using SQL Query

Given below is the Copy Table method using the SQL Query approach using 'SELECT INTO Statement'. This statement copies all columns and data from an existing table to a new table name provided.

Syntax:

SELECT * INTO <NewTableName> FROM <ExistingTableName>

Example: Here the 'ExistingTable' name is the name of the table which exists in the current database selected, and from which a new table copy needs to be created. The 'NewTableName' is the name of the new table where the copy is created.

Query:

SELECT * INTO ProductsNewCopy FROM Products

Output:

ProductsTable
ProductsNewCopy Table

Explanation: In the above example the table 'Products' is the existing table and 'ProductsNewCopy' is the new table with all data from 'Products' is created. Above is the Output of the new table 'ProductsNewCopy' which is exactly same as the table 'Products'.

2. Using SQL Server Management Studio (SSMS)

Below are the steps for copying table using the SQL Server Management Studio.

Step 1: Login to Microsoft SQL Server Management Studio

Step 2: Go to the Databases section and select the database from where you like to copy a Table

SSMS-View
SQL Management Studio

Step 3: Right click on the selected database to view the popup menu. Select 'Tasks' menu from the popup Menu

Tasks_ImportData

Step 4: Select 'Import Data' sub menu from the 'Tasks' menu. The SQL Server Import Export Wizard will be displayed.

Step 5: Press 'Next' button at the bottom of the Import Export Wizard window. The 'Choose a Data Source' window will be displayed.

SelectDataSourceAndDatabase
Choose Data Source

Step 6: Click on the 'Data Source' combo list box from the 'Choose a Data Source' as shown above.

Step 7: Select the Data source 'SQL Server Native Client 11.0' option. The version number 11.0 can vary based on the SQL Server version.

Input the server name of the SQL Server used when log in.

Step 8: In 'Authentication' section, select the 'Use Windows Authentication'. If the database is logged in using the SQL Server Authentication, then select 'Use SQL Server Authentication' and then input the 'User name' and 'Password' in the respective fields.

Step 9: Select the database name from the list to set the Source Database to copy table. All options for steps 6 to 9 are set in the 'Choose a Data Source' window as shown above.

Step 10: After all required data (Data Source, Server Name, Authentication, Database) in this page is filled, then click the button 'Next>' from the 'Choose a Data Source' window

Step 11: In the next window 'Choose a Destination', select the Destination details like Data Source, Server Name, Authentication and Database (options same as data source window in step 5).

Step 12: In the 'Specify Table Copy or Query' window, select the first option 'Copy data from one or more tables or views' and press 'Next'.

SpecifyTableCopy
Specify Table Copy or Query

Step 13: In the next window 'Select Source Tables and Views' option, select the table or tables to copy and input the destination table name to copy the selected table.

SelectTable
Select Source Tables

In this example for source, 'Customers' table is selected and the destination table name 'Customers_SSMS_Copy' is given. Press 'Next' button. The 'Save and Run Package' window will be displayed.

Step 14: Select the 'Run Immediately' option from 'Save and Run Package' screen. Then click 'Next' button. The 'Complete the Wizard' window will be displayed to confirm the options selected.

CompleteWizard
Complete the Wizard

Press 'Finish' button to run the final step in the wizard to copy the table selected. The 'The Execution was successful' message received if everything was correct.

ExecutionSuccess
Execution success

Step 15: Click the database name and Tables list to view the table which was copied as below.

ViewCopiedTable
View Copied table in SSMS

Conclusion

Overall, Copying tables in SQL Server can be done efficiently using SQL queries or SQL Server Management Studio. Whether you prefer the flexibility of writing your SQL queries or the user-friendly interface of SSMS, SQL Server offers versatile options to duplicate tables, making data management tasks more manageable.


Next Article
PostgreSQL - Copy Table

J

johnsupakin
Improve
Article Tags :
  • SQL Server
  • Databases

Similar Reads

  • PostgreSQL - Copy Table
    In PostgreSQL, the copy table functionality is a powerful feature that allows us to efficiently duplicate existing tables, including their structure and data. This capability is essential for various database management tasks such as backing up data, migrating tables, or testing modifications in a s
    4 min read
  • PL/SQL Copy Table
    Copying tables in PL/SQL is a common task in database management. It involves duplicating the structure and data of an existing table into a new one. This operation can be accomplished using the CREATE TABLE AS SELECT statement, which allows for the creation of a new table based on the result set of
    3 min read
  • SQL Server ALTER TABLE
    In SQL Server, there are various commands to Add, Update, and Delete a Database Schema called DDL or Data Definition Language commands. A Table in a database is part of the database schema and the 'ALTER TABLE Moify Column' command is used to make changes to the database table column data type, colu
    5 min read
  • SQL Server Describe Table
    SQL Server is a widely used Relational Database Management System (RDBMS) that allows users to create and manage databases effectively. When working with databases in SQL Server it is essential to understand the schema of the tables present in the database. Describing a table means getting informati
    4 min read
  • PostgreSQL - Copy a Table
    This article will focus on copying an existing table to a new table in PostgreSQL. This might come in handy while creating new tables that would either have the same data or data of the same table with certain operations performed on them. Ways to Copy a TableWe will discuss the following 3 cases to
    3 min read
  • CREATE TABLE in SQL Server
    SQL Server provides a variety of data management tools such as querying, indexing, and transaction processing. It supports multiple programming languages and platforms, making it a versatile RDBMS for various applications. With its robust features and reliability, SQL Server is a popular choice for
    4 min read
  • SQL Server ALTER TABLE DROP COLUMN
    In SQL Server, there could be some situations when we may have to delete or drop a column from a table. Sometimes the column in a table was created wrongly or maybe it is no longer required and has become obsolete. So, to drop a column from a table, the ALTER TABLE, DROP COLUMN SQL query is used. In
    4 min read
  • SQL CREATE TABLE
    In SQL, creating a table is one of the most essential tasks for structuring your database. The CREATE TABLE statement defines the structure of the database table, specifying column names, data types, and constraints such as PRIMARY KEY, NOT NULL, and CHECK. Mastering this statement is fundamental to
    5 min read
  • SQL Server TRUNCATE TABLE
    The TRUNCATE TABLE command in SQL Server allows you to rapidly and effectively remove every record from a table while maintaining the table structure. The TRUNCATE TABLE command is a more lightweight operation that is usually faster for large datasets than the DELETE statement, which eliminates rows
    6 min read
  • SQL Server UPDATE JOIN
    In the expansive realm of SQL Server, the UPDATE JOIN operation emerges as a potent tool for modifying data within tables by combining information from multiple sources. Unlike a traditional UPDATE statement that modifies a single table, UPDATE JOIN enables the modification of records based on condi
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences