SQL Store Procedure Column Name List

We can get all column list of store procedure using sys.dm_exec_describe_first_result_set_for_object function as below example

First create Store procedure. for example

CREATE PROCEDURE SP_Get_All_Employee_List
AS
BEGIN
    SET NOCOUNT ON;
    SELECT * FROM dbo.EMPLOYEE_MASTER WHERE 1=2
END

This SP return Employee_Master table columns.

Now use sys.dm_exec_describe_first_result_set_for_objec fun for SP_Get_All_Employee_List as:

SELECT name
FROM sys.dm_exec_describe_first_result_set_for_object
(
  OBJECT_ID(‘dbo.SP_Get_All_Employee_List’),
  NULL
);

It will return all columns as row:

sql_14042017

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s