Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artemavramenko/sqldump
Simple SQL Server database dumper
https://github.com/artemavramenko/sqldump
backup csharp mssql mssql-database mssql-tools mssqlserver script-generator sql-server
Last synced: about 2 months ago
JSON representation
Simple SQL Server database dumper
- Host: GitHub
- URL: https://github.com/artemavramenko/sqldump
- Owner: ArtemAvramenko
- License: mit
- Created: 2019-03-23T13:15:28.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T21:36:44.000Z (12 months ago)
- Last Synced: 2024-04-28T19:04:29.547Z (8 months ago)
- Topics: backup, csharp, mssql, mssql-database, mssql-tools, mssqlserver, script-generator, sql-server
- Language: C#
- Homepage:
- Size: 34.2 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SqlDump
Simple SQL Server database dumper. Shipped as source-only [NuGet package](https://www.nuget.org/packages/SqlDump.Sources).# Installing
* Package Manager: `Install-Package SqlDump.Sources`
* .NET command line: `dotnet add package SqlDump.Sources`# Example
``` csharp
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](https://raw.githubusercontent.com/ArtemAvramenko/SqlDump/master/Tests/Data.sql)# Lecacy System.Data.SqlClient
Add SQL_CLIENT_LEGACY to project defines.# ProgressChanged event
``` csharp
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");
}
};
```