How to Quickly Create a Copy of a Table using Transact-SQL
2014-03-01 15:59
603 查看
The easiest way to create a copy of a table is to use a Transact-SQL command. Use SELECT INTO to extract all the rows from an existing table into the new table. The new table must not exist already. The following example will copy the Customers table under the Sales schema to a new table calledCurrCustomers under the BizDev schema:
SELECT * INTO BizDev.CurrCustomers FROM Sales.Customers
You can also create the new table from a specific subset of columns in the original table. In this case, you specify the names of the columns to copy after the SELECT keyword. Any columns not specified are excluded from the new table. The following example copies specific columns to a new table:
SELECT CustName, Address, Telephone, Email INTO BizDev.CurrCustomers
FROM Sales.Customers
原文: http://technet.microsoft.com/en-us/magazine/dd401720.aspx
SELECT * INTO BizDev.CurrCustomers FROM Sales.Customers
You can also create the new table from a specific subset of columns in the original table. In this case, you specify the names of the columns to copy after the SELECT keyword. Any columns not specified are excluded from the new table. The following example copies specific columns to a new table:
SELECT CustName, Address, Telephone, Email INTO BizDev.CurrCustomers
FROM Sales.Customers
原文: http://technet.microsoft.com/en-us/magazine/dd401720.aspx
相关文章推荐
- How-to find the SQL that using lots of temp tablespace in Oracle
- How to update multiple columns of one table using values from another table?
- How To Change the Partition Column Of A Partitioned Table Using DBMS_Redefinition [ID 846405.1]
- SQL: How to get a series of dates in sql using connect by
- CodeSnip: How to Get Id of the Record Using ASP.NET and SQL Server 2000
- sql table data copy to exel using vba
- Using SQL*Loader to create an external table
- How to use outline levels to create a table of contents (TOC) in Word 2003 and in Word 2002
- Using SQL*Loader to create an external table
- How To Change the Partition Column Of A Partitioned Table Using DBMS_Redefinition [ID 846405.1]
- How to record log of specified package by using log4j
- How to collate SQL_Latin1_General_CP1_CI_AS using IN operator
- How to create SQL 2012 cluster without alwayson feature
- How to copy files between sites using JavaScript REST in Office365 / SharePoint 2013
- How to create water Ripple effect using HTML5 canvas
- [Windows Azure] How to Create and Configure SQL Database
- How to Get the Frequency Table of a Categorical Variable as a Data Frame in R
- How To Partition Existing Table Using DBMS_Redefinition [ID 472449.1]
- How to set CellSpacing and CellPadding attributes of Table
- How to implement a many-to-many relationship using Linq to Sql ? (转)