Zdarzenia
31 mar, 23 - 2 kwi, 23
Największe wydarzenie szkoleniowe sql, sieci szkieletowej i usługi Power BI. 31 marca – 2 kwietnia. Użyj kodu FABINSIDER, aby zaoszczędzić $400.
Zarejestruj się już dziśTa przeglądarka nie jest już obsługiwana.
Przejdź na przeglądarkę Microsoft Edge, aby korzystać z najnowszych funkcji, aktualizacji zabezpieczeń i pomocy technicznej.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL database in Microsoft Fabric
SQL Server supports exporting data in bulk (bulk data) from a SQL Server table and importing bulk data into a SQL Server table or nonpartitioned view.
SQL Server supports bulk exporting data from a SQL Server table and for bulk importing data into a SQL Server table or nonpartitioned view. The following basic methods are available.
Method | Description | Imports data | Exports data |
---|---|---|---|
bcp utility | A command-line utility (Bcp.exe) that bulk exports and bulk imports data and generates format files. | Yes | Yes |
BULK INSERT statement | A Transact-SQL statement that imports data directly from a data file into a database table or nonpartitioned view. | Yes | No |
INSERT ... SELECT * FROM OPENROWSET(BULK...) statement | A Transact-SQL statement that uses the OPENROWSET bulk rowset provider to bulk import data into a SQL Server table by specifying the OPENROWSET(BULK...) function to select data in an INSERT statement. | Yes | No |
SQL Server Import and Export Wizard | The wizard creates simple packages that import and export data between many popular data formats including databases, spreadsheets, and text files. | Yes | Yes |
Ważne
For rules about using a comma-separated value (CSV) file as the data file for a bulk import of data into SQL Server, see Prepare Data for Bulk Export or Import (SQL Server).
Uwaga
Only the bcp utility is supported by Azure Synapse Analytics for importing and exporting delimited files.
The bcp utility, BULK INSERT, and INSERT ... SELECT * FROM OPENROWSET(BULK...) all support the use of a specialized format file that stores format information for each field in a data file. A format file might also contain information about the corresponding SQL Server table. The format file can be used to provide all the format information that is required to bulk export data from and bulk import data to an instance of SQL Server.
Ważne
You cannot use BCP to import data from or export data to Azure Blob Storage into Azure SQL Database. Use BULK INSERT or OPENROWSET to import from or export to Azure Blob Storage.
Format files provide a flexible way to interpret data as it is in the data file during import, and also to format data in the data file during export. This flexibility eliminates the need to write special-purpose code to interpret the data or reformat the data to the specific requirements of SQL Server or the external application. For example, if you are bulk exporting data to be loaded into an application that requires comma-separated values, you can use a format file to insert commas as field terminators in the exported data.
SQL Server supports two kinds of format files: XML format files and non-XML format files.
The bcp utility is the only tool that can generate a format file. For more information, see Create a Format File (SQL Server). For more information about format files, see Format Files for Importing or Exporting Data (SQL Server).
Uwaga
In cases when a format file is not supplied during a bulk export or import operations, you can override the default formatting at the command line.
Zdarzenia
31 mar, 23 - 2 kwi, 23
Największe wydarzenie szkoleniowe sql, sieci szkieletowej i usługi Power BI. 31 marca – 2 kwietnia. Użyj kodu FABINSIDER, aby zaoszczędzić $400.
Zarejestruj się już dziśSzkolenie
Moduł
Dowiedz się, jak i kiedy używać usługi Azure Import/Export w celu kopiowania dużych ilości danych z platformy Azure
Dokumentacja
Zachowaj wartości null lub wartości domyślne podczas importowania zbiorczego - SQL Server
W przypadku importowania zbiorczego w programie SQL Server zarówno bcp, jak i BULK INSERT używają wartości domyślnych do zastąpienia wartości null. W obu przypadkach można zachować wartości puste.
Dowiedz się, jak używać instrukcji Transact-SQL do zbiorczego importowania danych z pliku do tabeli programu SQL Server lub usługi Azure SQL Database, w tym zagadnień dotyczących zabezpieczeń.
Używanie pliku formatu do zbiorczego importowania danych - SQL Server
W programie SQL Server można użyć pliku formatu w operacjach importowania zbiorczego. Plik formatu mapuje pola pliku danych na kolumny tabeli.