Consider the following stored procedure for fetching some data
SELECT
MatType_Id as 'ID', MatType_Code as 'Code', MatType_Name as 'Name',
Status_Id as 'Sid',
CASE
WHEN Status_Id = 1 THEN 'Active'
ELSE 'In Active'
END AS Status
FROM
MM.MM_MATTYPE
I want to get all column 'alias' names in above stored procedure which are ID
, Code
, Name
, Sid
and status
through a query.
I tried with the following query
select referenced_minor_name
from sys.dm_sql_referenced_entities('Sp_Name','object')
But its returning only actual column names MatType_Id
, MatType_Code
, MatType_Name
, Status_Id
and its not returning the last column status
Please someone help me to get all column alias names of a stored procedure in SQL Server.