Data can be imported and exported from Microsoft® SQL Server™ using several tools and Transact-SQL statements. You can also write your own programs to import and export data using the programming models and application programming interfaces (APIs) available with SQL Server.
Methods for copying data to and from SQL Server include:
The DTS package can also transform data during the import or export process.
The replication technology in SQL Server allows you to make duplicate copies of your data, move those copies to different locations, and synchronize the data automatically so that all copies have the same data values. Replication can be implemented between databases on the same server or different servers connected by LANs, WANs, or the Internet.
For more information, see Overview of Replication.
For more information, see SELECT.
It is possible to select data from an arbitrary OLE DB provider, allowing data to be copied from external data sources into SQL Server.
For more information, see INSERT.
A distributed query that selects data from another data source can also be used to specify the data to be inserted.
For more information, see Distributed Queries.
The method chosen to import or export data depends on a variety of user requirements, the most common being:
Required functionality |
DTS wizards |
Replication |
bcp |
BULK INSERT |
SELECT INTO / INSERT |
---|---|---|---|---|---|
Import text data | YES | YES | YES | YES (1) | |
Export text data | YES | YES | |||
Import from ODBC data sources | YES | YES | |||
Export to ODBC data sources |
YES | YES | |||
Import from OLE DB data sources | YES | YES | YES (1) | ||
Export to OLE DB data sources | YES | YES | |||
Graphical user interface | YES | YES | |||
Command prompt/batch scripts | YES | YES | YES | ||
Transact-SQL scripts | YES | YES | YES | ||
Automatic scheduling | YES | YES | YES (2) | YES (2) | |
Ad hoc import/export | YES | YES | YES | YES | |
Recurring import/export | YES | YES | YES | ||
Maximum performance | YES | YES | |||
Data transformation | YES | ||||
Programmatic interface | YES | YES | YES | ||
(1) Using a distributed query retrieving data from an external source by using an OLE DB provider. | |||||
(2 ) By explicitly creating a job scheduled using SQL Server Agent. |
bcp Utility | Programming DTS Applications |
BULK INSERT | Data Transformation Services Import and Export Wizards |