SQL Replication Extension for VS Code

Welcome to the SQL Replication Extension for Visual Studio Code! This extension makes it easy to manage SQL Server replication directly from your favorite IDE.

Features

  • 🔄 Set up and manage SQL Server replication
  • 📊 Monitor replication status and health
  • 🚀 Create and modify publications and subscriptions
  • 🛠 Configure replication settings
  • 📝 View detailed replication logs
  • ⚡ Quick actions for common replication tasks

Quick Start

  1. Install the extension from the VS Code marketplace
  2. Connect to your SQL Server instance
  3. Start managing your replication configuration

For detailed instructions, check out our Getting Started guide.

Why This Extension?

Managing SQL Server replication traditionally requires using SQL Server Management Studio or complex SQL scripts. This extension brings that functionality directly into VS Code, making it more accessible and integrated with your development workflow.

Requirements

  • Visual Studio Code 1.60.0 or higher
  • SQL Server 2016 or higher
  • Appropriate permissions on your SQL Server instance

Support

Having issues? Check out our:

Contributing

We welcome contributions! See our Contributing Guide for details on how to get involved.

Getting Started

This guide will help you get up and running with the SQL Replication Extension for VS Code.

Installation

  1. Open VS Code
  2. Press Ctrl+P (Windows/Linux) or Cmd+P (macOS)
  3. Type ext install sqlrepl
  4. Click "Install"

Prerequisites

Before using the extension, ensure you have:

  • SQL Server 2016 or higher installed
  • Appropriate permissions to configure replication
  • SQL Server Agent running on your instance

First Steps

  1. Open the SQL Replication View

    • Click the SQL Replication icon in the Activity Bar
    • Or use the command palette (Ctrl+Shift+P) and type "SQL Replication: Show Explorer"
  2. Add a Connection

    • Click the "+" button in the SQL Replication view
    • Enter your server details:
      Server: your-server-name
      Authentication: SQL Server or Windows
      Username: your-username (if using SQL Server auth)
      Password: your-password (if using SQL Server auth)
      
  3. Configure Distributor

    • Right-click your server in the tree view
    • Select "Configure Distribution"
    • Follow the wizard to set up distribution

Next Steps

Troubleshooting

If you encounter any issues:

  1. Check the Output panel (Ctrl+Shift+U) and select "SQL Replication" from the dropdown
  2. Verify SQL Server Agent is running
  3. Ensure you have appropriate permissions
  4. See our troubleshooting guide for more help

Need Help?

Installation

Basic Usage

Connecting to SQL Server

Managing Publications

This guide covers how to create and manage SQL Server replication publications using the SQL Replication Extension.

Understanding Publications

A publication is a collection of articles (tables, stored procedures, etc.) that you want to replicate to other databases. The SQL Replication Extension supports two types of publications:

  • Snapshot Publications: Create a complete copy of all articles at a specific point in time
  • Transactional Publications: Continuously replicate changes from the publisher to subscribers

Creating a Publication

  1. Access the Publications View

    • Expand your server in the SQL Replication view
    • Right-click the "Publications" folder
    • Select "Create Publication"
  2. Configure Distribution If distribution isn't configured yet, the extension will guide you through setting it up:

    • Choose a distribution database name (default: "distribution")
    • Specify a working directory for snapshot files
    • Configure security settings
  3. Choose Publication Type Select either:

    • Snapshot: For periodic full data synchronization
    • Transactional: For continuous change replication
  4. Name Your Publication

    • Enter a unique name for your publication
    • Select the database containing the articles to publish
  5. Select Articles

    • Choose the tables you want to replicate
    • The extension automatically filters out system tables

Managing Existing Publications

Viewing Publications

  • Expand your server in the SQL Replication view
  • Open the "Publications" folder to see all publications
  • Click on a publication to view its properties

Monitoring Status

  • Check the status indicators next to each publication
  • View agent jobs associated with the publication
  • Access detailed agent history and logs

Common Tasks

  • Start/Stop Agents: Use the play/stop buttons next to agent items
  • View History: Click the history icon to see detailed agent logs
  • Add Subscriptions: Right-click a publication to add subscribers

Best Practices

  1. Naming Conventions

    • Use descriptive names for publications
    • Include the type (snapshot/transactional) in the name
    • Consider including the database name for clarity
  2. Performance Considerations

    • Limit the number of articles to what's necessary
    • Consider table size when choosing publication type
    • Monitor snapshot folder disk space
  3. Security

    • Use Windows Authentication when possible
    • Create dedicated service accounts for replication
    • Regularly review permissions
  4. Maintenance

    • Monitor agent status regularly
    • Set up alerts for failed jobs
    • Keep snapshot folder clean

Troubleshooting

Common Issues

  1. Publication Creation Fails

    • Verify distribution is properly configured
    • Check SQL Server Agent is running
    • Ensure sufficient permissions
  2. Snapshot Generation Issues

    • Verify snapshot folder permissions
    • Check available disk space
    • Review agent job history
  3. Article Access Errors

    • Verify schema permissions
    • Check for schema changes
    • Review article properties

Getting Help

If you encounter issues:

  1. Check the Output panel for detailed error messages
  2. Review the troubleshooting guide
  3. Search or file issues on GitHub

Managing Subscriptions

This guide explains how to create and manage subscriptions to SQL Server replication publications using the SQL Replication Extension.

Understanding Subscriptions

A subscription defines how a database receives replicated data from a publication. The SQL Replication Extension supports two types of subscriptions:

  • Push Subscriptions: The distributor pushes changes to subscribers
  • Pull Subscriptions: Subscribers request changes from the distributor

Creating a Subscription

  1. Access the Subscriptions View

    • Expand your server in the SQL Replication view
    • Either:
      • Right-click a publication to subscribe to it
      • Right-click the "Subscriptions" folder to browse available publications
  2. Choose Subscription Type Select either:

    • Push: Better for immediate synchronization, managed at publisher
    • Pull: Better for occasional synchronization, managed at subscriber
  3. Configure Database

    • Select or create the subscriber database
    • The database name can be different from the publisher
  4. Set Synchronization Options Choose when to initialize the subscription:

    • Immediate: Start synchronization right away
    • Automatic: Wait for next snapshot
    • Manual: Initialize later manually
  5. Configure Security

    • Choose authentication mode for remote connections
    • Set up service account permissions if needed

Managing Existing Subscriptions

Viewing Subscriptions

  • Expand your server in the SQL Replication view
  • Open the "Subscriptions" folder
  • Click a subscription to view its properties

Common Tasks

  1. Reinitialize Subscription

    • Right-click the subscription
    • Select "Reinitialize"
    • Choose synchronization options
    • Monitor initialization progress
  2. Monitor Status

    • Check status indicators
    • View agent job history
    • Monitor synchronization progress
  3. Drop Subscription

    • Right-click the subscription
    • Select "Drop Subscription"
    • Confirm the removal

Best Practices

  1. Subscription Planning

    • Choose appropriate subscription type based on needs
    • Consider network bandwidth and latency
    • Plan for initialization time with large databases
  2. Performance Optimization

    • Monitor agent job performance
    • Schedule initializations during off-peak hours
    • Configure appropriate retry intervals
  3. Security Considerations

    • Use Windows Authentication when possible
    • Create dedicated service accounts
    • Regularly review permissions
  4. Maintenance Tasks

    • Monitor subscription status
    • Check for synchronization delays
    • Validate data consistency periodically

Troubleshooting

Common Issues

  1. Initialization Failures

    • Verify network connectivity
    • Check permissions on both sides
    • Review snapshot availability
  2. Synchronization Delays

    • Monitor distribution agent
    • Check for blocking processes
    • Verify agent job status
  3. Security Errors

    • Verify service account permissions
    • Check network security settings
    • Review firewall configurations

Getting Help

If you encounter issues:

  1. Check the Output panel for error messages
  2. Review agent job history
  3. See our troubleshooting guide
  4. File issues on GitHub

Monitoring Replication

This guide covers how to monitor SQL Server replication health and performance using the SQL Replication Extension.

Understanding Replication Agents

The extension helps you monitor different types of replication agents:

  1. Snapshot Agent

    • Creates initial data snapshots
    • Runs periodically for snapshot publications
    • Critical for initial synchronization
  2. Log Reader Agent

    • Monitors transaction log for changes
    • Moves transactions to distribution database
    • Essential for transactional replication
  3. Distribution Agent

    • Moves transactions from distributor to subscribers
    • Handles data delivery and conflict resolution
    • Key for maintaining synchronization

Monitoring Tools

Agent Status View

  • Expand a server in the SQL Replication view
  • Check agent status indicators:
    • â–ļī¸ Running
    • ⏚ī¸ Stopped
    • ⚠ī¸ Failed
    • 🔄 In Progress

Agent History

  1. Click the history icon next to any agent
  2. View detailed execution logs:
    • Run times
    • Status messages
    • Error details
    • Duration information

Performance Monitoring

  • Monitor agent execution times
  • Track synchronization latency
  • View error rates and patterns

Common Monitoring Tasks

Checking Agent Status

  1. Open the SQL Replication view
  2. Expand your server
  3. Look for status indicators
  4. Start/stop agents as needed

Viewing Job History

  1. Click the history icon
  2. Review recent executions
  3. Check for errors or warnings
  4. Analyze performance patterns

Troubleshooting Issues

  1. Check agent status
  2. Review error messages
  3. Examine job history
  4. Monitor system resources

Best Practices

Regular Monitoring

  1. Check Agent Status Daily

    • Verify all agents are running
    • Look for warning signs
    • Address issues promptly
  2. Review Performance Metrics

    • Monitor latency
    • Check resource usage
    • Track error rates
  3. Maintain History

    • Keep sufficient history
    • Archive important logs
    • Document issues and solutions

Setting Up Alerts

  1. Agent Failures

    • Monitor agent status
    • Set up email notifications
    • Define escalation procedures
  2. Performance Issues

    • Track synchronization delays
    • Monitor resource usage
    • Set thresholds for alerts
  3. Error Patterns

    • Look for recurring issues
    • Track error frequencies
    • Identify root causes

Troubleshooting

Common Issues

  1. Agent Not Starting

    • Check SQL Server Agent status
    • Verify service account permissions
    • Review error logs
  2. Synchronization Delays

    • Check network connectivity
    • Monitor system resources
    • Review agent job history
  3. Performance Problems

    • Check for blocking processes
    • Monitor disk space
    • Review network latency

Getting Help

If you need assistance:

  1. Check the Output panel for detailed logs
  2. Review our troubleshooting guide
  3. File issues on GitHub

Advanced Monitoring

Using System Views

The extension provides access to key system views:

  • Distribution agent history
  • Log reader agent history
  • Snapshot agent history
  • Replication performance metrics

Custom Monitoring

  • Set up custom monitoring schedules
  • Configure specific metrics to track
  • Create custom alert thresholds

Performance Optimization

  • Monitor resource usage
  • Track synchronization times
  • Identify bottlenecks
  • Optimize agent schedules

Configuration

Troubleshooting

Best Practices

Command Reference

This guide lists all available commands in the SQL Replication Extension for VS Code. Commands can be accessed through:

  • The Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
  • Context menus in the SQL Replication view
  • Toolbar buttons

Server Management

Add SQL Server Connection

  • Command ID: sqlrepl.addConnection
  • Icon: ➕
  • Description: Add a new SQL Server instance to manage replication
  • Access:
    • Command Palette
    • SQL Replication view toolbar
  • Options:
    • Server name
    • Authentication type (Windows/SQL)
    • Credentials (for SQL authentication)
    • Database name (optional)

Remove Server

  • Command ID: sqlrepl.removeServer
  • Icon: 🗑ī¸
  • Description: Remove a SQL Server connection from the extension
  • Access: Server context menu
  • Confirmation: Required before removal

Disable Publishing and Distribution

  • Command ID: sqlrepl.removeReplication
  • Icon: 🗑ī¸
  • Description: Remove all replication configuration from a server
  • Access: Server context menu
  • Confirmation: Required before removal
  • Effects:
    • Removes all publications
    • Drops distribution database
    • Disables distribution

Publication Management

Create Publication

  • Command ID: sqlrepl.createPublication
  • Icon: ➕
  • Description: Create a new replication publication
  • Access: Publications folder context menu
  • Options:
    • Publication type (Snapshot/Transactional)
    • Database selection
    • Article selection
    • Snapshot folder location
    • Security settings

Subscription Management

Create Subscription

  • Command ID: sqlrepl.createSubscription
  • Icon: ➕
  • Description: Create a new subscription to a publication
  • Access:
    • Publication context menu
    • Subscriptions folder context menu
  • Options:
    • Subscription type (Push/Pull)
    • Subscriber database
    • Synchronization options
    • Security settings

Reinitialize Subscription

  • Command ID: sqlrepl.reinitializeSubscription
  • Icon: 🔄
  • Description: Reinitialize an existing subscription
  • Access: Subscription context menu
  • Options:
    • Synchronization type
    • Snapshot application

Drop Subscription

  • Command ID: sqlrepl.dropSubscription
  • Icon: 🗑ī¸
  • Description: Remove an existing subscription
  • Access: Subscription context menu
  • Confirmation: Required before removal

Agent Management

Start Agent

  • Command ID: sqlrepl.startAgent
  • Icon: â–ļī¸
  • Description: Start a replication agent job
  • Access: Agent context menu (when stopped)
  • Applies to:
    • Snapshot Agent
    • Log Reader Agent
    • Distribution Agent

Stop Agent

  • Command ID: sqlrepl.stopAgent
  • Icon: ⏚ī¸
  • Description: Stop a running replication agent job
  • Access: Agent context menu (when running)
  • Confirmation: Required before stopping
  • Applies to:
    • Snapshot Agent
    • Log Reader Agent
    • Distribution Agent

View Agent History

  • Command ID: sqlrepl.viewAgentHistory
  • Icon: 📋
  • Description: View detailed agent job history
  • Access: Agent context menu
  • Information shown:
    • Execution times
    • Status
    • Error messages
    • Duration
    • Step details

General Commands

Refresh View

  • Command ID: sqlrepl.refreshTree
  • Icon: 🔄
  • Description: Refresh the SQL Replication view
  • Access:
    • SQL Replication view toolbar
    • Command Palette
  • Updates:
    • Server status
    • Publication list
    • Subscription status
    • Agent status

Show Welcome Message

  • Command ID: sqlrepl.showWelcomeMessage
  • Description: Display the extension's welcome message
  • Access: Command Palette
  • Content:
    • Quick start guide
    • Feature overview
    • Documentation links

Keyboard Shortcuts

The extension uses VS Code's standard keyboard shortcut system. You can customize these in your keyboard shortcuts settings:

  1. Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
  2. Type "Preferences: Open Keyboard Shortcuts"
  3. Search for "SQL Replication"
  4. Customize shortcuts as needed

Context Menu Reference

Different commands are available depending on the context:

Server Node

  • Add Connection
  • Remove Server
  • Disable Publishing and Distribution
  • Refresh

Publications Folder

  • Create Publication
  • Refresh

Publication Node

  • Create Subscription
  • Refresh

Subscriptions Folder

  • Create Subscription
  • Refresh

Subscription Node

  • Reinitialize Subscription
  • Drop Subscription
  • Refresh

Agent Node

  • Start/Stop Agent
  • View History
  • Refresh

Command Line Interface

The extension also supports command-line operations through VS Code's built-in terminal:

# Open VS Code with SQL Replication view
code --command "workbench.view.extension.replicationExplorer"

# Add a new connection (requires user interaction)
code --command "sqlrepl.addConnection"

# Refresh the replication view
code --command "sqlrepl.refreshTree"

Settings Reference

API Reference

Contributing

Changelog