Recently I’ve been playing around with SQL Azure. One of the current limitations of Azure, is no support for replication. I’ve been looking into different solutions to try and sync Azure data with my local SQL Server. The BCP utility and bulk import seem to be promising. Here is a simple example to copy the contents of a table from one DB table / server to another.

To export data to a binary data file, use the following command,
bcp "[sql query]" queryout [filename].bin -S [serveraddress] -U [username] -P [password] -d [database] -n
To import the data via the BCP utility, you can use the following command line,
bcp [table] in [filename].bin -S [serveraddress] -U [username] -P [password] -d [database] -n
Alternatively, you can also import the data via a SQL Query by using BULK INSERT
BULK INSERT  [tablename]
FROM '[path and filename]'
WITH (DATAFILETYPE='native')

To use these commands with Azure, you must be using version 10. bcp /v will tell you your version number.

Tags: , , , , , ,