Extracting data warehouses: bcp command line introduced by the data

Original: extracting data warehouses: bcp command line introduced by the data

 

In doing data warehousing, ETL is the most important development, and the first step in the ETL development, is extracted from the raw data to the OLTP system in the transition zone, and then the data in this transition zone conversion, final the load clean processed data into the data warehouse.

 

Target database is sql server, import data bcp command line. bcp manner relative to the other way, the faster is to do optimization.

The following line parameters used for the bcp command, attention to the case:  

-c to char as the storage type
-w -c and the like, as the storage type nchar used only when a copy of the data set unicode character
-T trusted connection with
-S sql server name server

in import data
out export data
queryout query export data

-U username
-P password
-F which row start importing
-L until the end of which line
-f file format
-x -f used together with, the file format used to produce xml format
-t field delimiter is designated "\ t "
-R & lt specified row delimiter is" \ n "

 

1, open ad hoc queries


   
   
  1. --修改高级参数
  2. sp_configure ' show advanced options ',1
  3. go
  4. --允许即席分布式查询
  5. sp_configure 'Ad Hoc Distributed Queries ',1
  6. go
  7. --如果配置的值不在合理范围(在最小值最大值范围内),那么可以强制覆盖
  8. reconfigure with override  
  9. go

2, the export file format

File format is used to specify the format of the table, which is several fields, data types what is behind the import, export data will be used.

By exporting formatting options, you can export directly, you do not need to write our own.

With a trusted connection Online:


   
   
  1. bcp wc .dbo .calendar format nul -f c:\ calendar .fmt
  2. -c -T -S pc0227gry\ mssqlserver2008

By user name, password:


   
   
  1. bcp wc.dbo.calendar format nul -f c:\calendar.fmt
  2. -c -Usa -Pxyz -S pc0227gry\mssqlserver2008

3, export the data file, the data can be saved to a remote server to export local files


   
   
  1. bcp wc.dbo.calendar out c:\calendar.txt -f c:\calendar.fmt
  2. -c -T -S PC0227GRY\MSSQLSERVER2008

4, import data


   
   
  1. bcp wc.dbo.calendar in c:\calendar.txt -c -f c:\calendar.fmt
  2. -Usa -Pxyz -S pc0227gry\mssqlserver2008

 

发布了416 篇原创文章 · 获赞 135 · 访问量 94万+

Guess you like

Origin www.cnblogs.com/lonelyxmas/p/12019932.html