DATABASE

SQL Server 2008 Command-Line Utilities : The bcp Command-Line Utility

10/10/2010 6:15:35 PM
You use the bcp (bulk copy program) tool to address the bulk movement of data. This utility is bidirectional, allowing for the movement of data into and out of a SQL Server database.

bcp uses the following syntax:

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] [-N] [-w] [-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]"]

Some of the commonly used options—other than the ones used to specify the database, such as user ID, password, and so on—are the –F and –L options. These options allow you to specify the first and last row of data to be loaded from a file, which is especially helpful in large batches. The –t option allows you to specify the field terminator that separates data elements in an ASCII file. The –E option allows you to import data into SQL Server fields that are defined with identity properties.

Tip

The BULK INSERT T-SQL statement and SSIS are good alternatives to bcp. The BULK INSERT statement is limited to loading data into SQL Server, but it is an extremely fast tool for loading data. SSIS is a sophisticated GUI that allows for both data import and data export, and it has capabilities that go well beyond those that were available in SQL Server 2000’s Data Transformation Services (DTS).

Other  
  •  SQL Server 2008 Command-Line Utilities : The tablediff Command-Line Utility
  •  SQL Server 2008 : Programming Objects - Implementing Functions
  •  Surviving Changes to Columns
  •  Surviving Changes to the Signature of a Stored Procedure
  •  Exploring the T-SQL Enhancements in SQL Server 2005 : The PIVOT and UNPIVOT Operators
  •  Exploring the T-SQL Enhancements in SQL Server 2005 : Common Table Expressions
  •  SQL Azure Data Access
  •  SQL Azure Architecture
  •  SQL Server : Transactions and Exceptions
  •  SQL Server : Exception Handling
  •  How Exceptions Work in SQL Server
  •  Surviving Changes to the Definition of a Primary or Unique Key
  •  Multi-Server Administration : Policy-Based Management
  •  Queries in SQL
  •  SQL Server 2008 : Roles
  •  Full-Text Indexing in SQL Server 2008
  •  sp_configure and SQL Server Management Studio
  •  Binding Application Data to the UI objects in Silverlight
  •  Performance Management Tools in SQL Server 2008
  •  Management Tools in SQL Server 2008
  •  
    Top 10
    SharePoint 2010 : The Search User Interface - The Search Center
    SharePoint 2010 : The Search User Interface - The Query Box
    SQL Server 2008 R2 : Database Maintenance - Executing a Maintenance Plan
    SQL Server 2008 R2 : Database Maintenance - Managing Maintenance Plans Without the Wizard
    Game Programming with DirectX : 3D Models - OBJ Models (part 3) - Preparing OBJ Files for Direct3D
    Game Programming with DirectX : 3D Models - OBJ Models (part 2) - Loading OBJ Files
    Game Programming with DirectX : 3D Models - OBJ Models (part 1) - Understanding the OBJ Model Format
    Game Programming with DirectX : 3D Models - Token Stream
    Game Programming with DirectX : 3D Models - Files in C++
    A Look At Truecrypt The Open Source Security Tool
    Most View
    Ipad : Presentations with Keynote - Building Your Own Slide
    SQL Server 2008 : Transact-SQL Programming - PIVOT and UNPIVOT
    Zalman LQ315 - Affordable Closed-Loop CPU Coolers
    Understanding the Architecture of SharePoint 2010 : Logical Architecture Components (part 1) - Service Architecture, Operating System Services
    Implementing Security in Windows 7 : Lock Your Computer
    WCF Services : Data Contract - Hierarchy
    Smartphones and Accessories - January 2013 (Part 1)
    Back To School - iPads In The Classroom (Part 2)
    Programmatic Security (part 6) - Assembly-Wide Permissions
    Razer Taipan - Shape And Size Make It Awkward
    iPod Docks
    Cooler Master CM Storm Mouse Pads
    Keep Selective Colour In Mono Conversions (Part 2)
    ASP.NET State Management : Working with a Session's State (part 2) - Lifetime of a Session
    Flashy Preview
    Pocket Friendly Sound
    The golden age of computer mags (Part 1)
    Our predictions for future tech (Part 1)
    Multifunction Printer Group Test (Part 2) : Epson Stylus Photo PX730WD, HP Photosmart 5520 e-ALL-in-ONE
    Recommended Buys: Everyday Computing – November 2012