我們的品牌

Impact-Company-Logo-English Black-01-177x54

歡迎造訪施耐德電機全球網站

歡迎訪問我們的網站
		
我们今天能为您提供什么帮助?
How to Create a Copy of a SQL Table or Database

Issue
Often when troubleshooting and\or correcting data issues, it is desirable to work on a temporary or subset of the production data
to in order to test a solution or to focus on a small portion of some particular data item(s).

Product
Struxureware Power Monitoring
Power Monitoring Expert
ION Enterprise
ION EEM

Environment
SQL Server 2005, SQL Server 2008 R2, SQL Server 2012, SQL Server 2014, SQL Server 2016, SQL Server 2017, SQL Server 2019, SQL Server 2022

Cause
Troubleshooting or correcting data issues.

Resolution
*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.*

An easy way to create a copy of a table is to use a SQL command.

Use SELECT INTO to extract all or a subset of the rows or from an existing table into the new table.
The new table must not exist already.

The following example will copy the Source table under the IonNetwork schema to a new table called MySource under the Test schema:
SELECT * INTO Test.MySource FROM IonNetwork.Source

You can also create the new table from a specific subset of rows in the original table.
In this case, you would append a Where clause to specify the criteria for only those rows you are interested in.
SELECT * INTO Test.MySource FROM IonNetwork.Source
Where Name like '%MySources%'

Additionally,  you could 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 ID, Name, SourceTypeID, Description INTO Test.MySource
FROM IonNetwork.Source
Additionally, entire databases or specific tables, views, stored procedures etc. can be copied via the Generate Scripts built in database task.
Right click on database -> Tasks -> Generate Scripts.
Generate Scripts
You can then set whether you want to copy just the schema of the table or the data along with the schema.
Data to copy

施耐德電機Taiwan

探索更多
系列:
探索更多
系列:

需要協助?

  • 產品選型工具

    快速輕鬆地為您的應用找到合適的產品和附件。

  • 取得報價

    立即線上提交您的銷售需求,專業團隊將主動聯繫您。

  • 購買地點

    輕鬆在您所在地區找到最近的施耐德電機經銷商。

  • 支援中心

    在同一位置找到滿足您所有需求的支援資源。

  • 產品文檔
  • 軟體下載
  • 產品選型工具
  • 產品替代和替換
  • 幫助和聯絡中心
  • 尋找我們的辦公室
  • 取得報價
  • 人才招募
  • 公司簡介
  • 舉報不當行為
  • 無障礙
  • 新聞中心
  • 投資者
  • 專業洞察
  • 台灣施耐德電機學院
  • 綠色影響力落差調查
  • Schneider Go Green 2025
  • 隱私政策
  • Cookie通告
  • 使用條款
  • Change your cookie settings