Monday, March 26, 2012

getting stored procedure information/properties from SQL DMO

Is there a way to get information such as the columns returned (aliased and non-aliased) from a stored procedure? I am using SQL 2000 dmo and can easily get dependent tables and other objects but I want to know which fields/columns from these tables are being used on my stored procedures.

Does sql 2005 DMO make this available?

Bill CC wrote:

Is there a way to get information such as the columns returned (aliased and non-aliased) from a stored procedure? I am using SQL 2000 dmo and can easily get dependent tables and other objects but I want to know which fields/columns from these tables are being used on my stored procedures.

Does sql 2005 DMO make this available?

No, due to the dynamic nature of stored procedures it is not possible to determine the names and types of the columns that will be returned statically. This is because the procedure may, depending on its logic, opt to return no rows, multiple rowsets, and/or even different sets of columns at each call. The only way to determine the columns that will be returned is to either read/parse the T-sql of the procedure, or call the procedure and see what it returns (for the current state of the database and set of input parameters).

For SQL 2005 see the SMO reference materials on MSDN. I don't believe the answer will change for SMO.

No comments:

Post a Comment