[Go] How to copy a table of SQL Server

Source: Internet
Author: User

This short article describes several ways to copy SQL Server tables. The first is the simplest way to copy a table to another table in the same database. What you need to remember is that the table's constraints and indexes are not copied when the table is copied. Here are the code templates and simple ways to use them:

1 Select *  into < Table >  from < Table > 2  3 Example: 4 Select *  into  from Employee

We can also copy only certain fields:

1 Select  into < Table > 2  from < Table > 3  4 Example: 5 Select  into Employee_backup 6  from Employee

The following method copies only the table structure and does not contain data:

1 Select *  into <DestinationTable>  from <SourceTable> where 1 = 22  3 Example:4 Select *  intoEmployee_backup fromEmployeewhere 1=2

The following method copies the table to another SQL Server server:

Select *  into < Database Table >  from < Database Table > Example: Select *  into Mydatabase2.dbo.employee_backup  from Mydatabase1.dbo.employee

[Go] How to copy a table of SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.