SQL Server Commands Reference
Command Structure
All SQL Server commands follow this consistent structure:
Copy code Expand code block snowflake-data-validation sqlserver < command> [options]
# Or use the shorter alias
sdv sqlserver < command> [options]
Where <command> is one of:
run-validation - Run synchronous validation
run-async-validation - Run asynchronous validation
generate-validation-scripts - Generate validation scripts
get-configuration-files - Get configuration templates
auto-generated-configuration-file - Interactive config generation
row-partitioning-helper - Interactive row partitioning configuration
column-partitioning-helper - Interactive column partitioning configuration
Run Synchronous Validation
Validates data between SQL Server and Snowflake in real-time.
Syntax
Copy code Expand code block snowflake-data-validation sqlserver run-validation \
--data-validation-config-file /path/to/config.yaml \
--log-level INFO
Options
--data-validation-config-file, -dvf (required)
Type: String (path)
Description: Path to YAML configuration file containing validation settings
Example: --data-validation-config-file ./configs/sqlserver_validation.yaml
--log-level, -ll (optional)
Type: String
Valid Values: DEBUG, INFO, WARNING, ERROR, CRITICAL
Default: INFO
Description: Logging level for validation execution
Example: --log-level DEBUG
Example Usage
Copy code Expand code block # Basic validation
sdv sqlserver run-validation \
--data-validation-config-file ./configs/sqlserver_validation.yaml
# Validation with debug logging
sdv sqlserver run-validation \
--data-validation-config-file ./configs/sqlserver_validation.yaml \
--log-level DEBUG
# Using full command name
snowflake-data-validation sqlserver run-validation \
-dvf /opt/validations/prod_config.yaml \
-ll INFO
Use Cases
Real-time validation during migration
Pre-cutover validation checks
Post-migration verification
Continuous validation in CI/CD pipelines
Run Asynchronous Validation
Performs validation using pre-generated metadata files without connecting to databases.
Syntax
Copy code Expand code block snowflake-data-validation sqlserver run-async-validation \
--data-validation-config-file /path/to/config.yaml
Options
--data-validation-config-file, -dvf (required)
Type: String (path)
Description: Path to YAML configuration file
Note: Configuration must specify paths to pre-generated metadata files
Example Usage
Copy code Expand code block # Run async validation
sdv sqlserver run-async-validation \
--data-validation-config-file ./configs/async_validation.yaml
# Using full command name
snowflake-data-validation sqlserver run-async-validation \
-dvf /data/validations/async_config.yaml
Prerequisites
Before running async validation:
Generate validation scripts using generate-validation-scripts
Execute the generated scripts on source and target databases
Ensure metadata files are available in the configured paths
Use Cases
Validating in environments with restricted database access
Separating metadata extraction from validation
Batch validation workflows
Scheduled validation jobs
Generate Validation Scripts
Generates SQL scripts for extracting metadata that can be executed separately.
Syntax
Copy code Expand code block snowflake-data-validation sqlserver generate-validation-scripts \
--data-validation-config-file /path/to/config.yaml
Options
--data-validation-config-file, -dvf (required)
Type: String (path)
Description: Path to YAML configuration file
Example Usage
Copy code Expand code block # Generate scripts
sdv sqlserver generate-validation-scripts \
--data-validation-config-file ./configs/validation.yaml
# Using full command name
snowflake-data-validation sqlserver generate-validation-scripts \
-dvf /opt/configs/script_generation.yaml
Output
The command generates SQL scripts in the output directory configured in your YAML file:
<output_directory>/
├── source_schema_queries.sql
├── source_metrics_queries.sql
├── source_row_queries.sql
├── target_schema_queries.sql
├── target_metrics_queries.sql
└── target_row_queries.sql
Use Cases
Generating scripts for execution by DBAs
Compliance requirements for query review
Environments where direct CLI database access is restricted
Manual execution and validation workflows
Get Configuration Templates
Retrieves example configuration files and optional query templates.
Syntax
Copy code Expand code block snowflake-data-validation sqlserver get-configuration-files \
--templates-directory ./my-templates \
--query-templates
Options
--templates-directory, -td (optional)
Type: String (path)
Default: Current directory
Description: Directory to save template files
Example: --templates-directory ./templates
--query-templates (optional)
Type: Flag (no value required)
Description: Include J2 (Jinja2) query template files for advanced customization
Example: --query-templates
Example Usage
Copy code Expand code block # Get basic templates in current directory
sdv sqlserver get-configuration-files
# Save templates to specific directory
sdv sqlserver get-configuration-files \
--templates-directory ./my-project/templates
# Include query templates for customization
sdv sqlserver get-configuration-files \
--templates-directory ./templates \
--query-templates
# Using short flags
sdv sqlserver get-configuration-files -td ./templates --query-templates
Output Files
Without --query-templates flag:
<templates_directory>/
└── sqlserver_validation_template.yaml
With --query-templates flag:
<templates_directory>/
├── sqlserver_validation_template.yaml
└── query_templates/
├── sqlserver_columns_metrics_query.sql.j2
├── sqlserver_row_count_query.sql.j2
├── sqlserver_compute_md5_sql.j2
└── snowflake_columns_metrics_query.sql.j2
Use Cases
Starting a new validation project
Learning configuration options
Customizing validation queries for specific needs
Creating organization-specific templates
Auto-Generate Configuration File
Interactive command to generate a configuration file by prompting for connection parameters.
Syntax
Copy code Expand code block snowflake-data-validation sqlserver auto-generated-configuration-file
Options
This command has no command-line options. All input is provided through interactive prompts.
Interactive Prompts
The command will prompt for the following information:
SQL Server host
Hostname or IP address of SQL Server
Example: sqlserver.company.com
SQL Server port (default: 1433)
Port number for SQL Server connection
Press Enter to accept default
SQL Server username
Authentication username
Example: migration_user
SQL Server password
Authentication password (hidden input)
Not displayed on screen for security
SQL Server database
Name of the database to validate
Example: production_db
SQL Server schema
Schema name within the database
Example: dbo
Trust server certificate (default: no)
Options: yes/no
Set to “yes” for self-signed certificates
Encrypt connection (default: yes)
Options: yes/no/optional
Controls SSL/TLS encryption
Output path for configuration file
Where to save the generated YAML file
Example: ./configs/my_validation.yaml
Example Session
Copy code Expand code block $ sdv sqlserver auto-generated-configuration-file
SQL Server host: sqlserver.company.com
SQL Server port [1433]:
SQL Server username: migration_user
SQL Server password: ********
SQL Server database: production_db
SQL Server schema: dbo
Trust server certificate (yes/no) [no]: no
Encrypt connection (yes/no/optional) [yes]: yes
Output path for configuration file: ./configs/sqlserver_config.yaml
Configuration file generated successfully: ./configs/sqlserver_config.yaml
Generated Configuration
The command generates a basic YAML configuration file:
Copy code Expand code block source_platform : SqlServer
target_platform : Snowflake
output_directory_path : ./validation_results
source_connection :
mode : credentials
host : sqlserver.company.com
port : 1433
username : migration_user
password : " <hidden>"
database : production_db
trust_server_certificate : " no"
encrypt : " yes"
target_connection :
mode : default
validation_configuration :
schema_validation : true
metrics_validation : true
row_validation : false
tables : []
Next Steps After Generation
Edit the configuration file to add:
Target connection details
Tables to validate
Validation options
Column selections and mappings
Review security settings:
Consider using environment variables for passwords
Update trust certificate and encryption settings as needed
Add table configurations:
Specify fully qualified table names
Configure column selections
Set up filtering where clauses
Test the configuration:
Copy code Expand code block sdv sqlserver run-validation \
--data-validation-config-file ./configs/sqlserver_config.yaml
Use Cases
Quick setup for new users
Generating baseline configurations
Testing connectivity during setup
Creating template configurations for teams
Row Partitioning Helper
Interactive command to generate partitioned table configurations for large tables. This helper divides tables into smaller row partitions based on a specified column, enabling more efficient validation of large datasets.
Syntax
Copy code Expand code block snowflake-data-validation sqlserver row-partitioning-helper
Options
This command has no command-line options. All input is provided through interactive prompts.
How It Works
The table partitioning helper:
Reads an existing configuration file with table definitions
For each table, prompts whether to apply partitioning
If partitioning is enabled, collects partition parameters
Queries the source database to determine partition boundaries
Generates new table configurations with WHERE clauses for each partition
Saves the partitioned configuration to a new file
Interactive Prompts
The command will prompt for the following information:
Configuration file path
Path to existing YAML configuration file
Example: ./configs/sqlserver_validation.yaml
For each table in the configuration:
a. Apply partitioning? (yes/no)
Whether to partition this specific table
Default: yes
b. Partition column (if partitioning)
Column name used to divide the table
Should be indexed for performance
Example: transaction_id, created_date
c. Is partition column a string type? (yes/no)
Determines quoting in generated WHERE clauses
Default: no (numeric)
d. Number of partitions
How many partitions to create
Example: 10, 50, 100
Example Session
Copy code Expand code block $ sdv sqlserver row-partitioning-helper
Generate a configuration file for SQL Server table partitioning. This interactive
helper function processes each table in the configuration file, allowing users to
either skip partitioning or specify partitioning parameters for each table.
Configuration file path: ./configs/sqlserver_validation.yaml
Apply partitioning for production_db.dbo.fact_sales? [Y/n]: y
Write the partition column for production_db.dbo.fact_sales: sale_id
Is ' sale_id' column a string type? [y/N]: n
Write the number of partitions for production_db.dbo.fact_sales: 10
Apply partitioning for production_db.dbo.dim_customer? [Y/n]: n
Apply partitioning for production_db.dbo.transactions? [Y/n]: y
Write the partition column for production_db.dbo.transactions: transaction_date
Is ' transaction_date' column a string type? [y/N]: n
Write the number of partitions for production_db.dbo.transactions: 5
Table partitioning configuration file generated successfully!
Generated Output
The command generates partitioned table configurations with WHERE clauses:
Copy code Expand code block tables :
# Original table partitioned into 10 segments
- fully_qualified_name : production_db.dbo.fact_sales
where_clause : " sale_id >= 1 AND sale_id < 100000"
target_where_clause : " sale_id >= 1 AND sale_id < 100000"
# ... other table settings preserved
- fully_qualified_name : production_db.dbo.fact_sales
where_clause : " sale_id >= 100000 AND sale_id < 200000"
target_where_clause : " sale_id >= 100000 AND sale_id < 200000"
# ... continues for each partition
# Non-partitioned table preserved as-is
- fully_qualified_name : production_db.dbo.dim_customer
# ... original configuration
Use Cases
Large table validation : Break multi-billion row tables into manageable chunks
Parallel processing : Enable concurrent validation of different partitions
Memory optimization : Reduce memory footprint by processing smaller data segments
Incremental validation : Validate specific data ranges independently
Performance tuning : Optimize validation for tables with uneven data distribution
Best Practices
Choose appropriate partition columns:
Use indexed columns for better query performance
Prefer columns with sequential values (IDs, timestamps)
Avoid columns with highly skewed distributions
Determine optimal partition count:
Consider table size and available resources
Start with 10-20 partitions for tables with 10M+ rows
Increase partitions for very large tables (100M+ rows)
String vs numeric columns:
Numeric columns are generally more efficient
String columns work but may have uneven distribution
After partitioning:
Review generated WHERE clauses
Adjust partition boundaries if needed
Test with a subset before full validation
Column Partitioning Helper
Interactive command to generate partitioned table configurations for wide tables with many columns. This helper divides tables into smaller column partitions, enabling more efficient validation of tables with a large number of columns.
Syntax
Copy code Expand code block snowflake-data-validation sqlserver column-partitioning-helper
Options
This command has no command-line options. All input is provided through interactive prompts.
How It Works
The column partitioning helper:
Reads an existing configuration file with table definitions
For each table, prompts whether to apply column partitioning
If partitioning is enabled, collects the number of partitions
Queries the source database to retrieve all column names for the table
Divides the columns into the specified number of partitions
Generates new table configurations where each partition validates only a subset of columns
Saves the partitioned configuration to a new file
Interactive Prompts
The command will prompt for the following information:
Configuration file path
Path to existing YAML configuration file
Example: ./configs/sqlserver_validation.yaml
For each table in the configuration:
a. Apply column partitioning? (yes/no)
Whether to partition this specific table by columns
Default: yes
b. Number of partitions (if partitioning)
How many column partitions to create
Example: 3, 5, 10
Example Session
Copy code Expand code block $ sdv sqlserver column-partitioning-helper
Generate a configuration file for SQL Server column partitioning. This interactive
helper function processes each table in the configuration file, allowing users to
either skip column partitioning or specify column partitioning parameters for each table.
Configuration file path: ./configs/sqlserver_validation.yaml
Apply column partitioning for production_db.dbo.wide_table? [Y/n]: y
Write the number of partitions for production_db.dbo.wide_table: 5
Apply column partitioning for production_db.dbo.small_table? [Y/n]: n
Apply column partitioning for production_db.dbo.report_table? [Y/n]: y
Write the number of partitions for production_db.dbo.report_table: 3
Column partitioning configuration file generated successfully!
Generated Output
The command generates partitioned table configurations with column subsets:
Copy code Expand code block tables :
# Original table with 100 columns partitioned into 5 segments (20 columns each)
- fully_qualified_name : production_db.dbo.wide_table
use_column_selection_as_exclude_list : false
column_selection_list :
- column_a
- column_b
- column_c
# ... first 20 columns alphabetically
- fully_qualified_name : production_db.dbo.wide_table
use_column_selection_as_exclude_list : false
column_selection_list :
- column_d
- column_e
- column_f
# ... next 20 columns alphabetically
# ... continues for each partition
# Non-partitioned table preserved as-is
- fully_qualified_name : production_db.dbo.small_table
# ... original configuration
Use Cases
Wide table validation : Break tables with hundreds of columns into manageable chunks
Memory optimization : Reduce memory footprint by validating fewer columns at a time
Parallel processing : Enable concurrent validation of different column groups
Targeted validation : Validate specific column groups independently
Performance tuning : Optimize validation for tables with many LOB or complex columns
Best Practices
Determine optimal partition count:
Consider the total number of columns in the table
For tables with 50+ columns, start with 3-5 partitions
For tables with 100+ columns, consider 5-10 partitions
Column ordering:
Columns are divided alphabetically
Related columns may end up in different partitions
After partitioning:
Review generated column lists
Verify all required columns are included
Test with a subset before full validation
Combine with row partitioning:
For very large, wide tables, consider using both row and column partitioning
First partition by columns, then apply row partitioning to each column partition if needed
SQL Server Connection Configuration
SQL Server connections require specific configuration in the YAML file.
Connection Example
Copy code Expand code block source_connection :
mode : credentials
host : " sqlserver.company.com"
port : 1433
username : " sqlserver_user"
password : " secure_password"
database : " source_database"
trust_server_certificate : " no"
encrypt : " yes"
Connection Fields
mode (required)
Type: String
Valid Values: credentials
Description: Connection mode for SQL Server
host (required)
Type: String
Description: SQL Server hostname or IP address
Examples:
"sqlserver.company.com"
"192.168.1.100"
"sql-prod-01.internal.company.net"
port (required)
Type: Integer
Default: 1433
Description: SQL Server port number
Common Values:
1433 (default)
1434 (SQL Server Browser)
username (required)
Type: String
Description: SQL Server authentication username
Example: "migration_admin"
password (required)
Type: String
Description: SQL Server authentication password
Security Note: Consider using environment variables
database (required)
Type: String
Description: SQL Server database name
Example: "production_database"
trust_server_certificate (optional)
Type: String
Valid Values: "yes", "no"
Default: "no"
Description: Whether to trust the server certificate for SSL/TLS connections
Use Case: Set to “yes” for self-signed certificates
encrypt (optional)
Type: String
Valid Values: "yes", "no", "optional"
Default: "yes"
Description: Connection encryption setting
Recommendations:
Use “yes” for production
Use “optional” for development/testing
Use “no” only in secure internal networks
Connection Examples
Production Connection with SSL/TLS:
Copy code Expand code block source_connection :
mode : credentials
host : " sql-prod.company.com"
port : 1433
username : " prod_reader"
password : " ${SQL_SERVER_PASSWORD}" # From environment variable
database : " production_db"
trust_server_certificate : " no"
encrypt : " yes"
Development Connection:
Copy code Expand code block source_connection :
mode : credentials
host : " localhost"
port : 1433
username : " dev_user"
password : " dev_password"
database : " dev_database"
trust_server_certificate : " yes"
encrypt : " optional"
Self-Signed Certificate Connection:
Copy code Expand code block source_connection :
mode : credentials
host : " internal-sql.company.local"
port : 1433
username : " internal_user"
password : " secure_password"
database : " internal_db"
trust_server_certificate : " yes" # Required for self-signed certs
encrypt : " yes"
Complete SQL Server Examples
Example 1: Basic SQL Server Validation
Copy code Expand code block # Global configuration
source_platform : SqlServer
target_platform : Snowflake
output_directory_path : ./validation_results
max_threads : auto
# Source connection
source_connection :
mode : credentials
host : sqlserver.company.com
port : 1433
username : sql_user
password : sql_password
database : production_db
trust_server_certificate : " no"
encrypt : " yes"
# Target connection
target_connection :
mode : name
name : snowflake_prod
# Validation configuration
validation_configuration :
schema_validation : true
metrics_validation : true
row_validation : false
# Tables to validate
tables :
- fully_qualified_name : production_db.dbo.customers
use_column_selection_as_exclude_list : false
column_selection_list : []
index_column_list :
- customer_id
- fully_qualified_name : production_db.dbo.orders
use_column_selection_as_exclude_list : true
column_selection_list :
- internal_notes
- audit_log
where_clause : " order_date >= '2024-01-01'"
target_where_clause : " order_date >= '2024-01-01'"
Example 2: SQL Server with Column Mappings
Copy code Expand code block source_platform : SqlServer
target_platform : Snowflake
output_directory_path : /opt/validation/sqlserver
max_threads : 16
source_connection :
mode : credentials
host : sql-prod.company.com
port : 1433
username : migration_user
password : secure_password
database : legacy_db
trust_server_certificate : " no"
encrypt : " yes"
target_connection :
mode : default
validation_configuration :
schema_validation : true
metrics_validation : true
row_validation : true
max_failed_rows_number : 100
comparison_configuration :
tolerance : 0.01
tables :
- fully_qualified_name : legacy_db.dbo.customer_master
use_column_selection_as_exclude_list : false
column_selection_list :
- cust_id
- cust_name
- email_addr
- phone_num
column_mappings :
cust_id : customer_id
cust_name : customer_name
email_addr : email
phone_num : phone
index_column_list :
- cust_id
chunk_number : 20
Example 3: SQL Server Large Table Optimization
Copy code Expand code block source_platform : SqlServer
target_platform : Snowflake
output_directory_path : ./large_table_validation
max_threads : 32
source_connection :
mode : credentials
host : bigdata-sql.company.com
port : 1433
username : bigdata_reader
password : readonly_password
database : analytics_db
trust_server_certificate : " no"
encrypt : " yes"
target_connection :
mode : name
name : snowflake_analytics
validation_configuration :
schema_validation : true
metrics_validation : true
row_validation : true
max_failed_rows_number : 500
exclude_metrics : false
comparison_configuration :
tolerance : 0.005
tables :
- fully_qualified_name : analytics_db.dbo.fact_transactions
use_column_selection_as_exclude_list : true
column_selection_list :
- large_blob_column
- xml_metadata
index_column_list :
- transaction_id
chunk_number : 100
where_clause : " transaction_date >= '2024-01-01' AND amount > 0"
target_where_clause : " transaction_date >= '2024-01-01' AND amount > 0"
max_failed_rows_number : 1000
Example 4: SQL Server View Validation
Validate SQL Server views alongside tables for comprehensive migration verification.
Copy code Expand code block source_platform : SqlServer
target_platform : Snowflake
output_directory_path : ./view_validation
max_threads : auto
source_connection :
mode : credentials
host : sqlserver.company.com
port : 1433
username : view_validator
password : secure_password
database : ReportingDB
trust_server_certificate : " no"
encrypt : " yes"
target_connection :
mode : name
name : snowflake_reporting
validation_configuration :
schema_validation : true
metrics_validation : true
row_validation : true
# Tables to validate
tables :
- fully_qualified_name : ReportingDB.dbo.CUSTOMERS
use_column_selection_as_exclude_list : false
column_selection_list : []
index_column_list : [CUSTOMER_ID]
target_index_column_list : [CUSTOMER_ID]
# Views to validate
views :
# Basic view validation with index columns
- fully_qualified_name : ReportingDB.dbo.CUSTOMER_SUMMARY_VIEW
target_name : CUSTOMER_SUMMARY_VIEW
use_column_selection_as_exclude_list : false
column_selection_list : []
index_column_list : [CUSTOMER_ID]
target_index_column_list : [CUSTOMER_ID]
# View with specific columns
- fully_qualified_name : ReportingDB.dbo.SALES_METRICS_VIEW
target_name : SALES_METRICS_VIEW
use_column_selection_as_exclude_list : false
column_selection_list :
- REGION
- TOTAL_SALES
- ORDER_COUNT
index_column_list : [REGION, PERIOD]
target_index_column_list : [REGION, PERIOD]
# View with filtering and column mappings
- fully_qualified_name : ReportingDB.dbo.ACTIVE_ORDERS_VIEW
target_name : ACTIVE_ORDERS_VIEW
use_column_selection_as_exclude_list : false
column_selection_list : []
index_column_list : [ORDER_ID]
target_index_column_list : [ORDER_ID]
where_clause : " order_date >= '2024-01-01'"
target_where_clause : " order_date >= '2024-01-01'"
column_mappings :
ORD_ID : ORDER_ID
CUST_ID : CUSTOMER_ID
# View with different target name
- fully_qualified_name : ReportingDB.dbo.LEGACY_REPORT_VIEW
target_database : MODERN_DB
target_schema : ANALYTICS
target_name : MODERNIZED_REPORT_VIEW
use_column_selection_as_exclude_list : false
column_selection_list : []
index_column_list : [REPORT_ID]
target_index_column_list : [REPORT_ID]
Note: View validation creates temporary tables internally to materialize view data for comparison between SQL Server and Snowflake.
Troubleshooting SQL Server Connections
Issue: SSL/TLS Certificate Errors
Symptom:
Copy code Expand code block SSL certificate verification failed
Solution:
Set trust_server_certificate to “yes”:
Copy code Expand code block source_connection :
trust_server_certificate : " yes"
encrypt : " yes"
Issue: Connection Timeout
Symptom:
Copy code Expand code block Connection timeout: Unable to connect to SQL Server
Solutions:
Verify the host and port:
Copy code Expand code block telnet sqlserver.company.com 1433
Check firewall rules
Verify SQL Server is running and accepting connections
Test with SQL Server Management Studio (SSMS)
Issue: Authentication Failed
Symptom:
Copy code Expand code block Login failed for user 'username'
Solutions:
Verify credentials are correct
Check SQL Server authentication mode (mixed mode required)
Ensure user has necessary permissions:
Copy code Expand code block -- Grant read permissions
GRANT SELECT ON SCHEMA::dbo TO migration_user;
GRANT VIEW DEFINITION ON SCHEMA::dbo TO migration_user;
Issue: Database Not Found
Symptom:
Copy code Expand code block Cannot open database "database_name"
Solutions:
Verify database name is correct
Check user has access to the database:
Copy code Expand code block USE database_name ;
SELECT * FROM sys. tables ;
Ensure database is online and accessible
Best Practices for SQL Server
Security
Use encrypted connections in production:
Copy code Expand code block source_connection :
encrypt : " yes"
trust_server_certificate : " no"
Store passwords securely:
Use environment variables
Use secret management systems
Avoid hardcoding passwords
Use read-only accounts:
Copy code Expand code block CREATE USER migration_reader WITH PASSWORD = ' secure_password' ;
GRANT SELECT ON SCHEMA::dbo TO migration_reader;
Enable chunking for large tables:
Copy code Expand code block tables :
- fully_qualified_name : large_table
chunk_number : 50
Use WHERE clauses to filter data:
Copy code Expand code block tables :
- fully_qualified_name : transactions
where_clause : " date >= '2024-01-01'"
Optimize thread count:
Copy code Expand code block max_threads : 16 # Adjust based on server capacity
Data Quality
Start with schema validation:
Copy code Expand code block validation_configuration :
schema_validation : true
metrics_validation : false
row_validation : false
Add metrics validation:
Copy code Expand code block validation_configuration :
schema_validation : true
metrics_validation : true
row_validation : false
Enable row validation selectively:
Copy code Expand code block validation_configuration :
row_validation : true
tables :
- fully_qualified_name : critical_table
# Row validation enabled for this table