Database Reference
In-Depth Information
direction
is
in
or
out
, depending on whether you're copying data into the
database or out of the database.
•
filename
is the filename you're copying data to or from.
•
servername
is the name of the server you're copying data to or from.
•
username
is the username used to connect to either the local or SQL Azure
database.
•
password
is the password associated with the username.
Let's get started by exporting the data from your source database.
•
Exporting the Data
Begin by copying data out of your local SQL instance. Open a command prompt, and type the command
shown in Figure 5-17. Enter your own values for the server name, the target directory, and the username
and password for your local server. (The password is blanked out in Figure 5-17.)
Figure 5-17
. Using bcp to export data
Notice that in this example you're using the
out
keyword for the direction parameter. That's because
you're copying data
out
of SQL Server.
The
-n
parameter performs the bulk-copy operation using the native database data types of the
data. The
-q
parameter executes the
SET QUOTED_IDENTIFIERS ON
statement in the connection between
the bcp utility and your SQL Server instance.
After you type in the command, press the Enter key to execute the bcp utility. In mere milliseconds,
105 rows are exported and copied to the
user.dat
file. Now, do the same for the Docs and UserDocs
tables.
Importing the Data
The next step is to copy the data into the cloud—specifically, to your SQL Azure TechBio database. The
syntax for copying
into
a database is very similar to the syntax for copying data
out
. You use the
in