protected void ScriptTableData() { if (!exportParams.ScriptDataAsSql) { return; } foreach (string tableName in exportParams.TablesToScriptData) { SqlTable table = database.Tables[tableName]; if (table == null) { string msg = string.Format( "Cannot find the table {0} in the database {1}", tableName, database.Name); throw new SqlExporterException(msg); } // get sproc script with drop statement and comments string sql = table.ScriptData(SqlScriptType.Comments); string objectName = table.Name + " Data"; writer.WriteTableDataScript(objectName, sql); UpdateProgress(objectName); } }
/// <summary> /// Generates table data inserts and updates to sync two tables in /// different databases. /// </summary> /// <param name="migrator">The data migrator instance.</param> /// <param name="source">The source table to script all data from.</param> /// <param name="writer">The script writer strategy.</param> protected virtual void ScriptTableData(IDataMigrator migrator, ITable source, IScriptWriter writer) { Throw.If(source, "source").IsNull(); Throw.If(writer, "writer").IsNull(); string name = DbObjectName.CreateDbObjectName(source); messageManager.OnScriptMessage( string.Format("Starting table data scripting on table {0}.", name)); script = new SqlScript(); script = migrator.ScriptAllData(source, script); writer.WriteTableDataScript(name, script.ToScript()); messageManager.OnScriptMessage( string.Format("Finished table data scripting on table {0}.", name)); }
protected virtual void ScriptTableDataDifferences(ITable sourceTable, ITable targetTable, IScriptWriter writer) { Throw.If(sourceTable, "sourceTable").IsNull(); Throw.If(targetTable, "targetTable").IsNull(); Throw.If(writer, "writer").IsNull(); string name = DbObjectName.CreateDbObjectName(sourceTable); messageManager.OnScriptMessage( string.Format("Starting table data difference scripting on table {0}.", name)); script = new SqlScript(); DifferentialDataMigrator migrator = new DifferentialDataMigrator(); script = migrator.ScriptDataDifferences(sourceTable, targetTable, script); writer.WriteTableDataScript(name, script.ToScript()); messageManager.OnScriptMessage( string.Format("Finished table data difference scripting on table {0}.", name)); }