Fixes generating data script
This commit is contained in:
@@ -291,28 +291,43 @@ namespace ServerExplorer.UI
|
||||
listCmds.Add("SET NOCOUNT ON;");
|
||||
listCmds.Add(string.Empty);
|
||||
|
||||
// Comandos de desactivacion de FKs
|
||||
foreach (TablaDesc t in db.Tablas)
|
||||
{
|
||||
string tableName = string.Format("{0}.{1}", t.Esquema, t.Nombre);
|
||||
listCmds.Add(string.Format("ALTER TABLE {0} NOCHECK CONSTRAINT all;", tableName));
|
||||
}
|
||||
//// Comandos de desactivacion de FKs
|
||||
//foreach (TablaDesc t in db.Tablas)
|
||||
//{
|
||||
// string tableName = string.Format("{0}.{1}", t.Esquema, t.Nombre);
|
||||
// listCmds.Add(string.Format("ALTER TABLE {0} NOCHECK CONSTRAINT all;", tableName));
|
||||
//}
|
||||
//listCmds.Add("GO");
|
||||
//listCmds.Add(string.Empty);
|
||||
|
||||
// Desactivar todas las FKs
|
||||
listCmds.Add("-- Disable all constraints");
|
||||
listCmds.Add("EXEC sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'");
|
||||
listCmds.Add("GO");
|
||||
listCmds.Add(string.Empty);
|
||||
|
||||
// Prepara informacion a exportar
|
||||
foreach (TablaDesc t in db.Tablas)
|
||||
{
|
||||
string tableName = string.Format("{0}.{1}", t.Esquema, t.Nombre);
|
||||
listCmds.Add(string.Format("PRINT '*** Importing data of {0}....';", tableName));
|
||||
List<string> listCmdsTableData = ExportData(tableName);
|
||||
listCmds.AddRange(listCmdsTableData);
|
||||
}
|
||||
|
||||
// Comandos de activacion de FKs
|
||||
foreach (TablaDesc t in db.Tablas)
|
||||
{
|
||||
string tableName = string.Format("{0}.{1}", t.Esquema, t.Nombre);
|
||||
listCmds.Add(string.Format("ALTER TABLE {0} WITH CHECK CHECK CONSTRAINT all;", tableName));
|
||||
}
|
||||
//// Comandos de activacion de FKs
|
||||
//foreach (TablaDesc t in db.Tablas)
|
||||
//{
|
||||
// string tableName = string.Format("{0}.{1}", t.Esquema, t.Nombre);
|
||||
// listCmds.Add(string.Format("ALTER TABLE {0} WITH CHECK CHECK CONSTRAINT all;", tableName));
|
||||
//}
|
||||
//listCmds.Add("GO");
|
||||
//listCmds.Add(string.Empty);
|
||||
|
||||
// Activar todas las FKs
|
||||
listCmds.Add("-- Enable all constraints");
|
||||
listCmds.Add("EXEC sp_MSforeachtable @command1='print ''?''', @command2='ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all'");
|
||||
listCmds.Add("GO");
|
||||
listCmds.Add(string.Empty);
|
||||
|
||||
// Escribir script
|
||||
@@ -341,6 +356,7 @@ namespace ServerExplorer.UI
|
||||
listCmds.Add(string.Format("SET IDENTITY_INSERT {0} ON;", tableName));
|
||||
listCmds.AddRange(listCmdsInsert);
|
||||
listCmds.Add(string.Format("SET IDENTITY_INSERT {0} OFF;", tableName));
|
||||
listCmds.Add("GO");
|
||||
listCmds.Add(string.Empty);
|
||||
|
||||
return listCmds;
|
||||
|
||||
Reference in New Issue
Block a user