Page 1 of 1
Stored Procedure Source SQL
Posted: Wed 15 Jun 2011 23:58
by chris.nillissen
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.
Posted: Thu 16 Jun 2011 13:25
by AndreyZ
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;