I use Sql Server 2008.
I want to get the column names and data types of the result set of a stored proc. How can I do it? Something like INFORMATION_SCHEMA would be helpful.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From an application you can inspect the potential result set by first issuing SET FMTONLY ON. However this is being phased out in future version of SQL Server in favor of a much more robust metadata discovery mechanism. In the meantime, the best you’re probably going to get is by using OPENQUERY against a loopback server. This assumes your stored procedure returns exactly one result set – if there are more than one, it isn’t quite going to work.
For example:
Note this also assumes that you aren’t using any CLR UDTs or alias types.