SQL Server exports and imports data in the following ways:
- The import and export interface is provided in SQL Server.
- The interface operation is divided into two modes: Copy data of one or more tables or views, and write query to specify the data to be transmitted, the first is to export all fields and records in tables and views, and the second is to control the exported fields and rows through SQL statements.
- UseSimple but useful SQL scriptsTable replication in.
- Another way is to use the BCP command in the command line to import and export data. Note that this is a good way to import and export large data volumes.
-- Export the entire table (out) BCP database name. DBO. Table name out c: \ currency.txt - S "database instance" - U "user" - P "password" - C -- Export using SQL statements (queryout) BCP" Select * From Database Name. DBO. Table Name "queryout c: \ currency.txt - S database instance - U "user" - P "password" - C -- Set the field separator and line separator (-c-t ","-R "\ n"). If you do not want to enter the field type, use it with-C. BCP" Select * From Database Name. DBO. Table Name "queryout c: \ currency.txt - S database instance - U "user" - P "password" - C - T "," - R "\ n" -- Specify the number of lines of imported data per batch, and the number of bytes of each network packet sent or received by the server (-K-b5000-a65535) BCP" Select * From Database Name. DBO. Table Name "queryout c: \ currency.txt - S database instance- U "user" - P "password" - C - T "," - R "\ n" - K - B5000 - A65535 -- Execute on the query analyzer (Exec master.. xp_mongoshell) Exec Master .. xp_mongoshell ' BCP "select * from database name. DBO. Table Name" queryout c: \ currency.txt-s database instance-U "user"-P "password"-C ' -- Generate a. SQL file from the SQL statement and then call -- Note: The folder name in the path cannot contain spaces. Exec Master .. xp_mongoshell ' Osql-s database instance-u user-P password-I c: \ mongoshelltest. SQL ' -- Import data to the currency table Exec Master .. xp_mongoshell ' BCP database name. DBO. Table Name in c: \ currency.txt-c-t ' -- You can also use the-F and-l options to select the record rows for data import. Exec Master .. xp_mongoshell ' BCP database name. DBO. Table Name in c: \ currency.txt-C-f 10-L 13-T '