Stored Procedure Source SQL

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
chris.nillissen
Posts: 1
Joined: Wed 15 Jun 2011 23:54

Stored Procedure Source SQL

Post by chris.nillissen » Wed 15 Jun 2011 23:58

Is there a way to get the source SQL of a stored procedure using SDAC?

I need to parse the actual SP SQL code rather than execute the SP.

AndreyZ

Post by AndreyZ » Thu 16 Jun 2011 13:25

Hello,

You can get the source code of a stored procedure in two ways:
1) by executing a query to INFORMATION_SCHEMA:

Code: Select all

MSQuery.SQL.Text := 'select ROUTINE_DEFINITION from INFORMATION_SCHEMA.ROUTINES Where ROUTINE_NAME=''stored_proc_name''';
MSQuery.Open;
2) by using the sp_helptext system stored procedure:

Code: Select all

MSQuery.SQL.Text := 'sp_helptext @objname = ''stored_proc_name''';
MSQuery.Open;

Post Reply