in src/PDWScripter/PDWscripter.cs [2746:2811]
private void getDDL(PDWscripter c, string outFile)
{
StreamWriter sw = null;
FileStream fs = null;
if (outFile != "")
{
fs = new FileStream(outFile, FileMode.Create);
sw = new StreamWriter(fs);
}
// get generated statistics
String description = "-- script generated the : " + String.Format("{0:d/M/yyyy HH:mm:ss}", DateTime.Now);
//get objects count
cmd.CommandText = "select count(1) from sys.schemas where name not in ('dbo','sys','INFORMATION_SCHEMA')";
int schemacount = (int)cmd.ExecuteScalar();
description += "\r\n-- objects scripted - tables = " + c.dbTables.Count.ToString() + " - schemas = " + schemacount.ToString();
sw.WriteLine(description);
String createUseDbTxt = "USE " + c.sourceDb + "\r\nGO\r\n";
sw.WriteLine(createUseDbTxt);
Console.Write("DDL>");
Console.Write("Objects to script - tables = " + c.dbTables.Count.ToString() + " - schemas = " + schemacount.ToString());
getSchemas(sw, false);
if (scriptMode == "Delta")
{
// Create temporary DEP schema
createDeployTmpSchemaTxt = "CREATE SCHEMA DEP;\r\nGO\r\n;\r\n";
sw.WriteLine(createDeployTmpSchemaTxt);
sw.WriteLine("DECLARE @COLUMNSNAME VARCHAR(8000) \r\n");
}
foreach (TableDef t in dbTables)
{
c.sourceTable = t.name;
c.destTable = t.name;
c.distribution_policy = t.distribution_policy;
c.getSourceColumns(false, false);
c.getClusteredIndex(false, false);
c.getPartitioning(false, false);
c.getNonclusteredIndexes(false, false);
c.getStats(false, false);
c.buildCreateTableText(sw);
}
if (scriptMode == "Delta")
{
// DROP temporary DEP schema
dropDeployTmpSchemaTxt = "DROP SCHEMA DEP;\r\nGO\r\n;\r\n";
sw.WriteLine(dropDeployTmpSchemaTxt);
}
if (outFile != "")
{
sw.Close();
}
Console.WriteLine("done");
}