mssql-to-pyspark-migration

Convert MSSQL T-SQL stored procedures into Databricks PySpark and Spark SQL code.

1|2|Updated Aug 10, 2026
One-click install
npx skills add https://github.com/TRRaveendra/AI-Agents-Databricks --skill mssql-to-pyspark-migration-trraveendra
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mssql-to-pyspark-migration
Source: https://github.com/TRRaveendra/AI-Agents-Databricks/tree/main/ai-agent-skills/skills_for_mssql_to_databricks
Command: npx skills add https://github.com/TRRaveendra/AI-Agents-Databricks --skill mssql-to-pyspark-migration-trraveendra

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Migrating Microsoft SQL Server stored procedures to Databricks is error-prone: procedural T-SQL constructs like cursors, temp tables, transactions, and dynamic SQL have no direct Spark equivalents, and naive conversions introduce SQL injection vulnerabilities and semantic bugs. This Skill provides a structured, security-first conversion workflow that preserves business logic while producing maintainable PySpark code. ## Core Features & Use Cases - Full T-SQL Coverage: Converts DML (INSERT, UPDATE, DELETE, MERGE), DDL, DRL/permissions, joins, CTEs, subqueries, set operators, window functions, temp tables, cursors, transactions, error handling, and dynamic SQL. - Security-First Rules: Enforces seven mandatory rules against SQL injection, including DataFrame API filtering, typed temp views, identifier whitelisting, and Spark-native timestamp functions. - Production Output Contract: Generates reusable Python functions with dry_run support, table_map abstraction, structured return metadata, validation plans, and risk documentation. - Use Case: Given a legacy SQL Server procedure that merges staging data into a customer table with TRY/CATCH and @@ROWCOUNT logging, produce an equivalent Delta Lake MERGE function with Python exception handling, explicit row-count metrics, and a differential validation plan. ## Quick Start Ask the agent to convert your MSSQL stored procedure to Databricks PySpark by pasting the T-SQL source code and requesting a production-ready Python function with a validation plan.

Frequently Asked Questions about mssql-to-pyspark-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a MSSQL stored procedure to PySpark?

Inventory the procedure's parameters, temp tables, cursors, transactions, and DML statements, then map each construct to Spark SQL or DataFrame API equivalents. The Skill generates a reusable Python function with dry_run support, table_map for environment-specific names, and a validation plan.

How to convert T-SQL MERGE to Databricks Delta Lake?

T-SQL MERGE maps directly to Delta Lake MERGE INTO with WHEN MATCHED and WHEN NOT MATCHED clauses. Deduplicate the source first using ROW_NUMBER or QUALIFY, since Delta MERGE fails when multiple source rows match one target row.

Can SQL Server cursors be migrated to Spark?

Cursors should be rewritten as set-based operations using joins, aggregations, window functions, or MERGE rather than row-by-row Python loops. Iterative loops are acceptable only for small datasets or unavoidable side effects, and the reason must be documented.

Does Databricks support SQL Server transactions?

Databricks does not provide multi-statement transaction scope like SQL Server BEGIN TRAN/COMMIT/ROLLBACK. Delta Lake gives ACID guarantees per operation, so multi-step logic needs idempotent task design, compensation logic, or Delta time travel for rollback.

Why is f-string SQL interpolation dangerous in PySpark conversions?

Interpolating user input into spark.sql strings creates SQL injection vulnerabilities, the top risk in MSSQL-to-Databricks conversions. Use DataFrame API filters with col() comparisons, typed temp views for parameterized MERGE, and whitelist validation for identifiers instead.

How do SQL Server permissions map to Unity Catalog?

GRANT SELECT maps directly, while INSERT, UPDATE, and DELETE map to GRANT MODIFY on Unity Catalog tables. GRANT EXECUTE has no direct equivalent and is replaced by workspace, notebook, and job access controls; DENY is replaced by least-privilege grants, row filters, and column masks.