Deploy database file and log file to different folders

le001yale001ya Posts: 14
edited January 14, 2009 7:23PM in SQL Packager Previous Versions
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

  • If you are creating a .EXE package, when you run through the SQL Packager wizard to create the executable, you get to the last pane and then click on "Extra Package Info..." button. Select the "Database Properties" tab and you then have the option to specify the Database folder and Log folder amongst other things.
  • The SQL Package Executable is run from the command line in silent mode (with the /quiet option). How can I specify the database folder and log folder without going through the wizard? Check the SQL Package 6.0 help file in the section titled "Running the package" using the command line for details.
  • private static void ParseCommandLine(string[] args, PackageExecutor packageExecutor)
    {
    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.");
    }
    }
Sign In or Register to comment.