SQL replication table and table structure

Source: Internet
Author: User
Copy table structure and data SQL statements

1: Copy table structure and data to a new table

SELECT * into destination database name. dbo. destination table name from the original table name

SELECT * Into My0735home.dbo.infoMianTest from Infomian

2: Back up part of the table column (do not write * and write out the list of columns)

Select Column Name 1, column name 2, column name 3 into destination database name. dbo. destination table name from the original table name

Select Id,title,mtype,stype,author,tel,nr to InfoMianTest2 from Infomian

3: Part of the backup table row (plus where condition)

SELECT * into destination database name. dbo. destination table name from the original table name where id<10

SELECT * into Infomiantest2 from Infomian where id<10

4: Back up part of a table column (do not write * and write out a list of columns) and a subset of rows (plus where condition)

Select Column Name 1, column name 2, column name 3 into destination database name. dbo. destination table name from the original table name where id<10

5: Copy only the structure of the table: for example: SELECT * Inot T1 from titles WHERE 1=2

6: Query results from multiple tables:

SELECT Title_id,title,pub_name into T3

From titles T INNER JOIN Publishers P

On t.pub_id=p.pub_id

SQL replication table and table structure

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.