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); } }
public void ExportTableData() { string dbname = ParamsData["database"]; string tablename = ParamsData["table"]; SqlServer server = (SqlServer)sessionData["server"]; server.Connect(); SqlDatabase database = server.Databases[dbname]; SqlTableCollection tables = database.Tables; SqlTable t = tables[tablename]; StringBuilder scriptResult = new StringBuilder(); scriptResult.Append(t.ScriptData(SqlScriptType.Comments)); server.Disconnect(); JsonResult = scriptResult.ToString(); }