SQL Server 2008 读书笔记(7):导入和导出数据
2013-02-01 16:24
225 查看
Lesson 1: Importing and Exporting Data
Quick Check
1. What are the data formats that BCP supports and the command-line switches for each format?
2. Which parameter do you specify to export data using a query?
3. The Import and Export Wizard is based on which feature of SQL Server?
4. Which sources and destinations is the Import and Export Wizard capable of using?
Quick Check Answers
1. BCP can work with data in either a character or native format. The –c switch
2. The queryout parameter is used to export the result set of a query.
3. The Import and Export Wizard uses a subset of the SSIS feature.
4. You can defi ne any source or destination for which you have an OLE DB provider.
Practice:
Lesson Summary
BCP is a lightweight, command-line utility that allows you to import and export data.
The BCP utility is not designed to provide data transformation or error-handling routines.
In addition to exporting the entire contents of a table or view, you can export the results of a query by using the queryout argument for the BCP utility.
BULK INSERT is a T-SQL command you can use only to import data.
The Import and Export Wizard, based on a subset of SSIS, allows you to move data directly between a source and destination without requiring the use of a fi le.
bcp {[[database_name.][owner].]{table_name | view_name} | "query"} {in | out | queryout | format} data_file [-mmax_errors] [-fformat_file] [-x] [-eerr_file] [-Ffirst_row] [-Llast_row] [-bbatch_size] [-n] [-c] [-w] [-N] [-V (60 | 65 | 70 | 80)] [-6] [-q] [-C { ACP | OEM | RAW | code_page } ] [-tfield_term] [-rrow_term] [-iinput_file] [-ooutput_file] [-apacket_size] [-Sserver_name[\instance_name]] [-Ulogin_id] [-Ppassword] [-T] [-v] [-R] [-k] [-E] [-h"hint [,...n]"]
bcp AdventureWorks.HumanResources.Department out c:\test\department.txt -n -SHOTEK –T bcp AdventureWorks.HumanResources.Department in c:\test\department.txt -c -SHOTEK -U<login> -P<password> bcp "SELECT Name, GroupName FROM HumanResources.Department" queryout c:\test\department.txt -n -SHOTEK –T
BULK INSERT [ database_name . [ schema_name ] . | schema_name . ] [ table_name | view_name ] FROM 'data_file' [ WITH ( [ [ , ] BATCHSIZE = batch_size ] [ [ , ] CHECK_CONSTRAINTS ] [ [ , ] CODEPAGE = { 'ACP' | 'OEM' | 'RAW' | 'code_page' } ] [ [ , ] DATAFILETYPE = { 'char' | 'native'| 'widechar' | 'widenative' } ] [ [ , ] FIELDTERMINATOR = 'field_terminator' ] [ [ , ] FIRSTROW =first_row ] [ [ , ] FIRE_TRIGGERS ] [ [ , ] FORMATFILE = 'format_file_path' ] [ [ , ] KEEPIDENTITY ] [ [ , ] KEEPNULLS ] [ [ , ] KILOBYTES_PER_BATCH =kilobytes_per_batch ] [ [ , ] LASTROW = last_row ] [ [ , ] MAXERRORS = max_errors ] [ [ , ] ORDER ( { column [ ASC | DESC ] } [ ,...n ] ) ] [ [ , ] ROWS_PER_BATCH = rows_per_batch ] [ [ , ] ROWTERMINATOR = 'row_terminator' ] [ [ , ] TABLOCK ] [ [ , ] ERRORFILE = 'file_name' ] )]
Quick Check
1. What are the data formats that BCP supports and the command-line switches for each format?
2. Which parameter do you specify to export data using a query?
3. The Import and Export Wizard is based on which feature of SQL Server?
4. Which sources and destinations is the Import and Export Wizard capable of using?
Quick Check Answers
1. BCP can work with data in either a character or native format. The –c switch
2. The queryout parameter is used to export the result set of a query.
3. The Import and Export Wizard uses a subset of the SSIS feature.
4. You can defi ne any source or destination for which you have an OLE DB provider.
Practice:
bcp AdventureWorks2008R2.HumanResources.Department out c:\test\department.txt -c -SWIN-N1NGJC5BOSR -T bcp AdventureWorks2008R2.HumanResources.Department out c:\test\department.bcp -n -SWIN-N1NGJC5BOSR -T
CREATE DATABASE AdventureWorksTest
Lesson Summary
BCP is a lightweight, command-line utility that allows you to import and export data.
The BCP utility is not designed to provide data transformation or error-handling routines.
In addition to exporting the entire contents of a table or view, you can export the results of a query by using the queryout argument for the BCP utility.
BULK INSERT is a T-SQL command you can use only to import data.
The Import and Export Wizard, based on a subset of SSIS, allows you to move data directly between a source and destination without requiring the use of a fi le.
相关文章推荐
- SQL Server 2008 导出数据与导入数据任务介绍
- SQL SERVER 2008 怎么导入和导出单张表的数据和结构
- SQL Server 2005/2008 导入导出数据常见报错
- SQL Server 2005/2008 导入导出数据常见报错解决方法
- SQL SERVER 2008 怎么导入和导出单张表的数据和结构
- SQL Server 2000/2008导入导出数据表
- sql server 2008 导入导出数据大全
- SQL Server 2008 导出数据与导入数据任务介绍
- sql server中三种导入导出数据方式(SQL语句、bcp、dts)
- SQL Server导出导入数据方法
- sql server 2008 导出一张表的数据
- SQL SERVER 和ACCESS以及execl的数据导入导出
- [转]不同版本的SQL Server之间数据导出导入,降级还原等
- SQL Server 2008支持将数据导出为 insert into 的脚本
- SQL Server与Excel Access之间数据的导入导出
- SQL Server 2008将数据导出为脚本 导出表中数据的sql
- SQL Server数据的导入导出
- SQL Server导出导入数据方法
- SQL Server导出导入数据方法
- SQL Server 2008导入、导出数据库