SQL replication table structure and data realization method _mssql

Source: Internet
Author: User
Use select in SQL Server ... INTO statement

According to the use of the situation can be divided into the following categories:

1. To implement a full table backup: For example: SELECT * Inot T1 from titles

2. Part of a backup table (write a list of columns without *) or a branch (add where Condition)

For example, SELECT title_id,title,price into T2 from titles-partial columns

SELECT * into T2 from titles Whree price>10– partial lines

SELECT Title_id,title,price into T2 from titles Whree price>10– partial rows and partial columns

3. Copy only the structure of the table: for example: SELECT * Inot T1 from titles where 1=2

4. Query results come from multiple tables: such as:

SELECT Title_id,title,pub_name into T3

From titles T INNER JOIN Publishers P

On t.pub_id=p.pub_id

5.select * into the name of the database to copy to. DBO. Table name from original database name. DBO. Table name

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.