Deploy database file and log file to different folders
le001ya
Posts: 14
Is there an option to create the database file and the database log file in separated locations when run the SQL Packager executable from the command line? What would be the work around if an option is not available?
Comments
{
string var;
packageExecutor.Retry = false ;
for (int nIndex = 0; nIndex < args.Length; nIndex++)
{
string arg = args[nIndex];
var = "/server:";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.ServerName = arg.Substring(var.Length).Trim();
if (packageExecutor.ServerName.Length == 0 && ((nIndex+1) < args.Length) )
{
packageExecutor.ServerName = args[++nIndex];
}
continue;
}
var = "/database:";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.DatabaseName = arg.Substring(var.Length).Trim();
if (packageExecutor.DatabaseName.Length == 0 && ((nIndex+1) < args.Length) )
{
packageExecutor.DatabaseName = args[++nIndex];
}
continue;
}
var = "/username:";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.UserName = arg.Substring(var.Length).Trim();
packageExecutor.IntegratedSecurity = false;
continue;
}
var = "/password:";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.Password = arg.Substring(var.Length);
packageExecutor.IntegratedSecurity = false;
continue;
}
var = "/quiet";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.Quiet = true;
continue;
}
var = "/makedatabase";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.MakeDatabase = true;
continue;
}
//begin custom code
var = "/databaselocation:";
if (arg.ToLower().StartsWith(var))
{
packageExecutor.DatabaseProperties.DatabaseLocation = arg.Substring(var.Length).Trim();
if (packageExecutor.DatabaseProperties.DatabaseLocation.Length == 0 && ((nIndex + 1) < args.Length))
{
packageExecutor.DatabaseProperties.DatabaseLocation = args[++nIndex];
}
continue;
}
var = "/loglocation:";
if (arg.ToLower().StartsWith(var))
{
packageExecutor.DatabaseProperties.LogLocation = arg.Substring(var.Length).Trim();
if (packageExecutor.DatabaseProperties.LogLocation.Length == 0 && ((nIndex + 1) < args.Length))
{
packageExecutor.DatabaseProperties.LogLocation = args[++nIndex];
}
continue;
}
//end custom code
var = "/presql:";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.PreSqlFile = arg.Substring(var.Length);
continue;
}
var = "/postsql:";
if(arg.ToLower().StartsWith(var))
{
packageExecutor.PostSqlFile = arg.Substring(var.Length);
continue;
}
}
if (packageExecutor.DatabaseName.Length == 0)
{
throw new ApplicationException("Database name cannot be empty.");
}
if (packageExecutor.ServerName.Length == 0)
{
throw new ApplicationException("SQL Server name cannot be empty.");
}
}