Skip to content

yanivetrogi/SQLScripter

Repository files navigation

SQLScripter v4.3.1.0

A powerful, secure, and zero-config SQL Server database scripting tool for .NET 8

.NET Platform License


πŸ“– Overview

SQLScripter is a professional-grade command-line tool that generates SQL Server schema scripts for SQL Server databases. It supports scripting tables, views, stored procedures, functions, indexes, logins, credentials jobs and many other database objects across multiple servers concurrently.

✨ Key Features

  • πŸ”’ Zero-Config Authentication - Automatic resolution of SQL, Windows, or Impersonated identities
  • πŸ›‘οΈ Secure Credential Storage - Windows DPAPI encryption for all account types
  • ⚑ Multi-threaded Processing - Process multiple servers concurrently (up to 100 threads)
  • πŸ“¦ ZIP Compression - Optional password-protected ZIP archives
  • 🎯 Selective Scripting - Choose specific databases and object types
  • 🧹 Automatic Cleanup - Automatic retention management for old scripts and archives
  • πŸ“ Advanced Logging - Global and per-server console output & color configuration
  • πŸ”„ Modern Architecture - Built on .NET 8 with async/await patterns

πŸš€ Quick Start

Basic Usage

  1. Configure servers in appsettings.json (just the server name!):

    {
      "Servers": [{ "SQLServer": "SQLSERVER01" }]
    }
  2. Add credentials (optional - only if current user doesn't have access):

    # For SQL Login
    SQLScripter.exe add SQLSERVER01 sa YourPassword
    
    # For Domain Service Account (Impersonation)
    SQLScripter.exe add SQLSERVER01 DOMAIN\svcacct YourPassword win
  3. Run the tool:

    SQLScripter.exe

πŸ”§ Configuration

Configuration is now incredibly streamlined.

Simple Configuration Example

{
  "SQLScripter": {
    "OutputFolder": "c:\\sqlscripter_out",
    "ZipFolder": true,
    "MaxConcurrentThreads": 10
  },
  "Servers": [
    {
      "SQLServer": "SQLSERVER01",
      "Databases": "all"
    }
  ]
}

Application Settings

Setting Default Description
OutputFolder c:\sqlscripter_out Output directory for scripts
ScriptOneFilePerObjectType false One file per object type vs. per object
ZipFolder true Create ZIP archive of output
ZipPassword - Password for ZIP archive (optional)
DeleteOutputFolderAfterZip false Delete folder after creating ZIP
MaxConcurrentThreads 25 Max concurrent server connections (1-100)
DaysToKeepFilesInOutputFolder 180 Automatic cleanup of folders and ZIPs older than X days

Server Settings

Setting Default Description
SQLServer - Server name or instance (e.g., SERVER01\INST)
Databases all Databases to script (semicolon-separated or all)
ObjectTypes all Object types to script (semicolon-separated or all)
WriteToConsole false Print progress for this server to console
ConsoleForeGroundColour White Color for this server's console output

πŸ› οΈ Advanced CLI Overrides

SQLScripter provides a robust CLI for ad-hoc tasks. You can override any appsettings.json configuration directly:

# 1. Target a specific server and database (ignores config list)
SQLScripter.exe --server PROD-SQL01 --database MarketingDB

# 2. Script only specific object types to a custom folder
SQLScripter.exe --types "Tables;Views;Procedures" --output "D:\SQL_Exports"

# 3. High-speed parallel run (50 threads) with ZIP disabled
SQLScripter.exe --threads 50 --zip false

# 4. Target multiple databases on one server
SQLScripter.exe --server "DEV-SQL" --database "Northwind;Pubs;AppLogs"

# 5. Legacy Mode: Quick script of specific types for ALL configured servers
SQLScripter.exe Tables Views Procedures

πŸ” Credential Management

Manage encrypted credentials safely from the CLI:

# Add a SQL login
SQLScripter.exe add SERVER01 sa MyPassword

# Add a Windows Account for Impersonation
SQLScripter.exe add SERVER01 "DOMAIN\svc_sql" "SecretPass" win

# List all stored credentials
SQLScripter.exe list

# Remove a specific credential
SQLScripter.exe remove SERVER01

Type SQLScripter.exe --help for the full list of flags.

πŸ’‘ Common Scenarios

Automated Nightly Backup

Run via Windows Task Scheduler to back up all databases to a central share: SQLScripter.exe --output "\\BackupServer\SQL_Scripts" --zip true

Quick Table Export for Developer

Just grab tables for a specific project: SQLScripter.exe --server PROD-DB --database "ProjectAlpha" --types "Tables" --zip false


πŸ”’ Automated Identity Resolution

SQLScripter follows a "Smart Choice" logic for every server:

  1. Stored SQL Account? ➑️ Connect using SQL Auth.
  2. Stored Windows Account? ➑️ Automatically impersonate domain user ➑️ Connect.
  3. No Stored Account? ➑️ Connect using your current identity.

πŸ“– Full Security Guide: Docs/CREDENTIALS_README.md


πŸ“Š Supported Object Types

Code Object Type Code Object Type
TABLES Tables (U) INDEXES Indexes (I)
VIEWS Views (V) FOREIGNKEYS Foreign Keys (F)
PROCEDURES Stored Procedures (P) TRIGGERS Triggers (TR)
FUNCTIONS Functions (FN) JOBS SQL Agent Jobs

(And many more... type all to script everything)


πŸ› οΈ Windows Event Log Setup

SQLScripter logs its lifecycle (Starts, Success, and Fatal Errors) to the Windows Application Event Log under the source SQLScripter.

Because Windows requires Administrative privileges to register a new Event Source for the first time, you have two options for deployment:

Option 1: One-Time Admin Run

Run the application as Administrator once on the target machine. It will automatically detect the missing source and register it.

# Run as Admin
SQLScripter.exe --help

Option 2: DevOps / PowerShell (Recommended)

Use the included Register-EventSource.ps1 script during your deployment or server setup phase. This script must be run with elevated permissions.

.\Register-EventSource.ps1

Once registered, the application will log events even when run by non-administrative service accounts.


πŸ—οΈ Architecture

  • .NET 8.0 - Modern cross-platform framework core
  • SMO - Latest SQL Server Management Objects
  • Zero-Config - Identity-aware service architecture
  • DPAPI - Enterprise-grade encryption

πŸ“š Further Documentation


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE.txt file for details.


Version: 4.3.1.0 (2026-02-03)
Made with ❀️ for SQL Server DBAs

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages