3

I have a stored procedure in Sql Server 2008 with below body, that inserts car then gets it:

ALTER PROCEDURE [dbo].[sp_Car_Insert]
    @RunDate VARCHAR(25),
    @CarNo NVARCHAR(50),
    @Volume INT,
    @Weight SMALLINT,
    @CarName NVARCHAR(50),
    @InUse BIT,
    @CarID TINYINT OUTPUT
AS
BEGIN
    SELECT @CarID = ISNULL(MAX(c.CarID), 0) + 1
    FROM   Car c

    INSERT INTO Car
      (
        CarID,
        RunDate,
        CarNo,
        Volume,
        [Weight],
        CarName,
        InUse,
        IsDeleted
      )
    VALUES
      (
        @CarID,
        @RunDate,
        @CarNo,
        @Volume,
        @Weight,
        @CarName,
        @InUse,
        0
      )

    SELECT *
    FROM   Car
    WHERE  CarID = @CarID
END

I want to know if there is a way to get selected Columns headers info in T-SQL or not? Is there any solution to get them?

For example: we can get headers of function tables by INFORMATION_SCHEMA.ROUTINE_COLUMNS table. Is there any info in sql server to get procedures returned headers?

Nima Rostami
  • 2,652
  • 3
  • 15
  • 23

1 Answers1

2

sys.dm_exec_describe_first_result_set_for_object

This dynamic management function takes an @object_id as a parameter and describes the first result metadata for the module with that ID. The @object_id specified can be the ID of a Transact-SQL stored procedure or a Transact-SQL trigger.

It only describes the first result set.

ta.speot.is
  • 26,914
  • 8
  • 68
  • 96