Home > SQL Azure > Move data to SQL Azure using BCP Tool

Move data to SQL Azure using BCP Tool


BCP is one of the best tool to transfer data to SQL Azure database. This is a high performance command line utility for data transfer between database system.

In this blog post, I am going to show you how to transfer a data from SQL Server 2012 database to SQL Azure.

Implementation

Step 1: BCP does not transfer table schema. So, we should prepare SQL Azure database with the necessary table before data migration.

pic1SQL Query:

CREATE TABLE [CreditCard](
    [CreditCardID] [int] NOT NULL,
    [CardType] [nvarchar](50) NOT NULL,
    [CardNumber] [nvarchar](25) NOT NULL,
    [ExpMonth] [tinyint] NOT NULL,
    [ExpYear] [smallint] NOT NULL,
    [ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_CreditCard_CreditCardID] PRIMARY KEY CLUSTERED 
(
    [CreditCardID] ASC
)
) 
GO

Step 2: Move data from source table to a data file

pic2

Command:

BCP sales.CreditCard out  <Drive>:\DataFile\CreditCard.dat -d
 Adventureworks2012 -S <Server name> -T -n -q

Step 3: Upload data from the data file to SQL Azure database.

pic3Command:

bcp dbo.CreditCard in :\DataFile\CreditCard.dat  -U <User Name>  -S tcp:<SQL Azure>.database.windows.net -n -q -d SQLServerRider

 

We have migrated the data to SQL Azure with 3 simple steps. Learn more about data migration to SQL Azure here.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: