SQLAzureMWBatchUpload Parameter DropOldDatabaseIfExists

Jan 25, 2012 at 7:01 PM

Is there a way with the command line parameter to override the config file setting DropOldDatabaseIfExists if the option is already set to true in the file?
It appears that the -d parameter only turns on the option.

Jan 26, 2012 at 2:27 AM



Now there is.  I modified the command parameter to be “-d { true | false }”.  If you don’t specify –d, then I use value specified in the config file.  Please check out v3.8.2 and see if it works for you.


Thanks for the catch,


Jan 26, 2012 at 4:42 PM


That was fast! 
I tried 3.8.2 and I am getting an error (see script and output below).  I haven't tried adding the "-d false" to my command line yet.
When I switch back to 3.8.1 (exe & dll) everything runs fine. 
It seems to be when the program gets to the 1st bcp line in my sql file.

Thank you,

Command Line

".\SQLAzureMWBatchUpload.exe" -i "ContentMenuSet.Import.sql" -o ".\ContentMenuSet.Import.log" -S server.database.windows.net -U username@server -P password -D databasename


DELETE FROM [dbo].[ViewMenuItems]

DELETE FROM [dbo].[SubMenuItems]

DELETE FROM [dbo].[ConfigMenuItems]

DELETE FROM [dbo].[MenuItems]

DELETE FROM [dbo].[Menus]

-- BCPArgs::[dbo].[Menus] in "dummydb.Menus.dat" -E -n -b 10000 -a 16384 -o "dummydb.Import.Menus.log"

-- BCPArgs::[dbo].[MenuItems] in "dummydb.MenuItems.dat" -E -n -b 10000 -a 16384 -o "dummydb.Import.MenuItems.log"

-- BCPArgs::[dbo].[ConfigMenuItems] in "dummydb.ConfigMenuItems.dat" -E -n -b 10000 -a 16384 -o "dummydb.Import.ConfigMenuItems.log"

-- BCPArgs::[dbo].[SubMenuItems] in "dummydb.SubMenuItems.dat" -E -n -b 10000 -a 16384 -o "dummydb.Import.SubMenuItems.log"

-- BCPArgs::[dbo].[ViewMenuItems] in "dummydb.ViewMenuItems.dat" -E -n -b 10000 -a 16384 -o "dummydb.Import.ViewMenuItems.log"


SQLAzureMWBatchUpload, Version
Process started at 1/26/2012 11:20:25 AM -- UTC -> 1/26/2012 5:20:25 PM ...
 -- Success:  DELETE FROM [dbo].[ViewMenuItems]
 -- Success:  DELETE FROM [dbo].[SubMenuItems]
 -- Success:  DELETE FROM [dbo].[ConfigMenuItems]
 -- Success:  DELETE FROM [dbo].[MenuItems]
 -- Success:  DELETE FROM [dbo].[Menus]

Unhandled Exception: System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
   at System.String.Remove(Int32 startIndex)
   at SQLAzureMWUtils.TargetProcessor.BCPUploadData(Server targetServer, String targetDatabase, AsyncUpdateStatus updateStatus, AsyncQueueBCPJob queueBCPJob, String bcpArgs, StringCollection& bcpUploadCommands)
   at SQLAzureMWUtils.TargetProcessor.ExecuteSQLonTarget(Server targetServer, String targetDatabase, String collation, String edition, Int32 dbSize, AsyncUpdateStatus updateStatus, AsyncQueueBCPJob queueBCPJob, String sqlToExecute, Boolean bDropDatabaseIfExists)
   at SQLAzureMWBatchUpload.Program.Process()
   at SQLAzureMWBatchUpload.Program.Main(String[] args)

Jan 27, 2012 at 2:20 AM

Hi Chris,


Just out of curiosity, did you save off your old SQLAzureMWBatchUpdate.exe.config file and use it over the new one?  I tried and tried to reproduce the issue that you were talking about and failed until I removed this line from the new config file:


    <add key="SpecialTableCharacters" value="\[[!\&quot;\#\$\w\s\.\'\-^-]+\]"/>


If you used your old config file, then this key is missing and it caused the exact error you mentioned.  Anyway, can you check and if it is not in your config file, please add it and see what happens?


I don’t like this section of my code and it has caused me a lot of problems.  I will have to rethink what I am doing here.  But I wanted to see if this was the cause of your problem.


As a side note, I noticed that your BCPArgs at the bottom of the script were like this:


-- BCPArgs::[dbo].[Menus] in "dummydb.Menus.dat" -E -n -b 10000 -a 16384 -o "dummydb.Import.Menus.log"


I was actually surprised that my code worked with that.  The reason is that there is no value between the first two ::


It should look more like this:


-- BCPArgs:128942:[dbo].[Menus] in "dummydb.Menus.dat" -E -n -b 10000 -a 16384 -o "dummydb.Import.Menus.log"


Where the 128942 is replaced with the number of records in your .dat file.  I use that number to determine the number of loops I need to make when chunking the data (see ChunkSize in config file).  I also use this number to verify that the number of records uploaded was the number of records expected.  I guess the number of rows you are uploading are smaller than the ChunkSize so it works.  Anyway, if you know the number of records in the bcp dat file, it should go in place of 128942.


Let me know if adding the SpecialTableCharacters key to the config file works for you.  I am traveling for the next week so my response will only be at night (sorry if I am slow in responding).




Jan 30, 2012 at 1:27 PM

Hello George,
The missing SpecialTableCharacters key was the issue.  I was reusing my config file from before.

Thank you for looking into this.