Dump your MSSQL database into file or stream using F# library or .NET CLI tool.
If you want to install this package manually, use usual NuGet package command
Install-Package SQLDumper
or using Paket
paket add SQLDumper
Library is rather simple:
open SQLDumper
SQLDumper.init "myconnectionstring"
|> SQLDumper.useGoStatements true // default
|> SQLDumper.statementsInTransaction 1000 // default
|> SQLDumper.rowsInStatement 100 // default
|> SQLDumper.ignoreTables ["ignore1";"ignore2"] // empty by default
|> MSSQL.dumpToFile "path/to/file.sql"
If you prefer using TextWriter
from BCL, you can use MSSQL.dumpToWriter
function.
To install .NET tool use this command
dotnet tool install SQLDumper.Tool
Again, this CLI tool is rather simple:
USAGE:
sqldump (-h | --help)
sqldump <connectionstring> <outputfile> [options]
OPTIONS [options]:
-h --help Shows help
--usego <bool> Use GO statements [default: True]
--statements <number> Number of statements in transaction [default: 1000]
--rows <number> Number of rows in transaction [default: 100]
--ignore <tables> Tables to ignore when doing SQL dump (use comma for more tables separation)
Thanks to @ArtemAvramenko for his SqlDump C# library used as reference project for this library.