Skip to content

ArtemAvramenko/SqlDump

Repository files navigation

SqlDump

Simple SQL Server database dumper. Shipped as source-only NuGet package.

Installing

  • Package Manager: Install-Package SqlDump.Sources
  • .NET command line: dotnet add package SqlDump.Sources

Example

private void GenerateBackupScript(string connectionString, string outputFile)
{
    var dumper = new SqlDumper.Dumper(connectionString);
    dumper.IgnoredTableNames = new[] { "__EFMigrationsHistory", "sysdiagrams" };
    using (var writer = File.CreateText(outputFile))
    {
        dumper.Dump(writer);
    }
}

See result

Support for sql_variant type

Support for the sql_variant type is still very limited and requires setting the RowsInStatement to 1.

Lecacy System.Data.SqlClient

Add SQL_CLIENT_LEGACY to project defines.

ProgressChanged Event

    dumper.ProgressChanged += (sender, e) =>
    {
        if (e.RowsDumped == 0)
        {
            logWriter.WriteLine($"Dumping {e.SchemaName}.{e.TableName}...");
        }
        if (e.RowsDumped > 0 && (e.IsCompleted || e.RowsDumped % 10000 == 0))
        {
            logWriter.WriteLine($"{e.RowsDumped} rows dumped...");
        }
        if (e.IsCompleted)
        {
            logWriter.WriteLine($"The table {e.SchemaName}.{e.TableName} has been dumped");
        }
    };

Packages

No packages published

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy