Skip to content

monoblaine/MsSqlDataDumpScriptSplitter

Repository files navigation

SQL Server Data Dump Script Splitter

This tool splits your huge SQL Server data dump scripts into smaller/executable chunks sqlcmd can handle.

Usage:

MsSqlDataDumpScriptSplitter.exe <pathToInputFile> <pathToOutputDir> [fileSizeLimitMB (defaults to 1024 MB)]

The reason for this tool to exist is that sqlcmd cannot handle files with size over 2 GBs (AFAIK). This tool splits the dump file by simultaneously reading and writing one byte at a time and when the number of bytes read exceeds the given limit it continues on writing to the current chunk until it finds a batch separator (Hard coded as GO).

Features

  • Tracks set identity_insert ... on/off statements and if insert statements span multiple files, set identity_insert ... on gets inserted to the beginning of the next file as needed.
  • Blindly adds set ansi_nulls on and set quoted_identifier on to the start of each file.

Assumptions

  • Batch separator is assumed to be GO
  • Dump file encoding is assumed to be UTF16 LE BOM

Executing The Splitted Files

You can use the following batch script to execute all the files sequentially.

for %%G in (*.sql) do sqlcmd /S <InstanceName> -E -i"%%G"

About

This tool splits your huge SQL Server data dump scripts into smaller/executable chunks sqlcmd can handle.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages