0

I have a stored procedure looking like this:

SELECT
    nTransactionId
    ,strInstrument
FROM dbo.Deals

I've read that for SQL Server 2012 I can use sp_describe_first_result_set, but is there any alternative for SQL Server 2008?

When I say I want the column names I mean nTransactionId and strInstrument. Even if the query doesn't return any result.

Many thanks!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MrProgram
  • 5,044
  • 13
  • 58
  • 98
  • possible duplicate of [Retrieve column definition for stored procedure result set](http://stackoverflow.com/questions/7368864/retrieve-column-definition-for-stored-procedure-result-set) – GarethD Sep 30 '14 at 10:11
  • @GarethD I can't use linked server for this. – MrProgram Sep 30 '14 at 10:27
  • In that case I am fairly sure you can't do it. As far as I know you 3 options: **1.** Upgrade to SQL Server 2012. **2.** Use a linked server (although it is only linking it to itself). **3.** Find a solution to the problem that doesn't require knowing the definition of the procedure result. – GarethD Sep 30 '14 at 10:32

1 Answers1

0

For that purpose I mostly use :

SET FMTONLY ON;

Returns only metadata to the client. Can be used to test the format of the response without actually running the query.

Have a look here: Sql Server SET FMTONLY (Transact-SQL)

This is what DataSet designer is using for example in order to get the parameteres of a procedure.

George Mavritsakis
  • 6,829
  • 2
  • 35
  • 42