Thursday, March 29, 2012

Field List from a Stored procedure

I am writing a utility that creates Java code to access a database. I am looking for a way to get a list of fields and types that are returned by an sproc. Is there any easy way to get this from the master? Do you need to parse the SQL? This list would be like what Visual Studio.NET shows, or interdev if I remember correctly.

Thanks,

Larrynot sure what exactly you looking for. try sp_helptext sproc_name|||I am looking for a way to get a list of the columns that will be in the recordset returned by a stored procedure. I need column name and type information.

sp_helptext seems to return the full contents of the sproc, which would require that I parse this, and any linked procedures, to get the info I am looking for. This is what I am trying to avoid.|||Do your procedures do SELECT only? You can use sp_depends and retrieve the structures of all dependent tables, but this will also include fields that your procedure does not include. It'll be easier to go after views.|||The procedures I am interested in do selects only. But they pull from other procedures and views.|||I am looking for something like that as well. So far I am using sp_sproc_columns to fetch the list of params from a SQL Server stored procedure.

There's nothing that I've found that will return a vertical list of outputs though. Ultimately I would like to display the fields returned by the sproc and their data types. Hopefully I won't have to re-invent the wheel by having to parse the sproc text.

I'll post back if I find anything else.

Thanks,

Doug

No comments:

Post a Comment