load-source-define

Retrieve original T-SQL definitions from SQL Server using sp_helptext.

Updated Oct 9, 2025
One-click install
npx skills add https://github.com/Kevin163/DatabaseSqlServer2PostgreSql --skill load-source-define
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: load-source-define
Source: https://github.com/Kevin163/DatabaseSqlServer2PostgreSql/tree/main/.claude/skills/load-source-define
Command: npx skills add https://github.com/Kevin163/DatabaseSqlServer2PostgreSql --skill load-source-define

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyodbc.

What problem does it solve?

Retrieves the original T-SQL definition text of database objects (stored procedures, views, and functions) from the source SQL Server to aid migration debugging, testing, and validation.

Core Features & Use Cases

  • Retrieve original T-SQL definitions for stored procedures, views, and functions using a simple Python script.
  • Save definitions to a file or display them for quick analysis, enabling comparisons with converted PostgreSQL scripts.
  • Supports debugging workflows such as analyzing migration failures, creating unit tests, and validating schema changes.

Quick Start

Run the script with --proc, --view, or --func to fetch a definition and optionally save it to a file.

Frequently Asked Questions about load-source-define

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

FAQPage Schema
How do I retrieve the original T-SQL definition of a stored procedure from SQL Server?

You can retrieve the T-SQL definition of a stored procedure by running a Python script that uses pyodbc to connect to SQL Server and calls sp_helptext. It handles the 255-character line splitting and preserves original line breaks for accurate definition extraction.

What is the best way to extract SQL Server view definitions for PostgreSQL migration debugging?

The best way to extract SQL Server view definitions for migration debugging is to fetch the original T-SQL text using sp_helptext. This allows you to compare the original source definitions directly with your converted PostgreSQL scripts to validate schema changes and troubleshoot errors.

Does sp_helptext split T-SQL definitions into 255-character lines when fetching source?

Yes, sp_helptext returns T-SQL definitions split into 255-character lines. The script handles this 255-character line splitting and preserves original line breaks to reconstruct the full definition text accurately for migration troubleshooting.

Can I use pyodbc to fetch and save SQL Server function definitions to a file?

Yes, you can use pyodbc to connect to SQL Server and fetch function definitions via sp_helptext. The script can save the retrieved T-SQL source text as a UTF-8 encoded file for later analysis or unit-test creation.

Why do I need original T-SQL definitions during database migration unit testing?

You need original T-SQL definitions during database migration unit testing to compare source SQL Server objects with converted PostgreSQL scripts. Fetching the exact source text enables accurate pre-conversion analysis, validates schema changes, and helps troubleshoot migration failures.

What database objects can I extract source definitions for using sp_helptext and pyodbc?

Using sp_helptext and pyodbc, you can extract source definitions for stored procedures, views, and functions from a SQL Server database. The script retrieves the original T-SQL text to support migration debugging, pre-conversion analysis, and unit-test creation workflows.