Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

828


Part V: Enterprise Data Management


FIGURE 31-19
Using bcp to export data from the on-premises Contact table.

After you type in the command, press the Enter key to execute the bcp utility. In mere
milliseconds, nearly 20,000 rows are exported and copied to the contact.dat fi le. Now, do
the same for the Employee table.

Importing the Data
The next step is to copy the data into the cloud — specifi cally, to your SQL Database
AWMini database. The syntax for copying into a database is similar to the syntax for copy-
ing data out. You use the in keyword and specify the server name and credentials for your
SQL Azure database instance, as shown in Figure 31-20.

After you type in the command, press Enter to execute the bcp utility. You can see in
Figure 31-20 that nearly 20,000 rows were imported into SQL Database within a matter of
seconds. You can use the same process now to import the Employee data.

A word of caution. If you are expecting a large number of rows to be imported but the
output states that only a single row was imported, with an unexpected end-of-fi le (EOF)
encountered, this error isn’t specifi c to SQL Database; the bcp utility has issues with col-
umns of the uniqueidentifier data type. You can fi nd posts and blogs all over the
Internet about this problem.

The solution is to execute the following T-SQL against the table in question in your SQL
Azure database instance:

c31.indd 828c31.indd 828 7/31/2012 10:00:31 AM7/31/2012 10:00:31 AM


http://www.it-ebooks.info
Free download pdf