TSQL - Aliases for column names from Stored Procedure results

Post date: Apr 3, 2015 8:46:13 PM

In Sql Server 2012 there was a feature introduced called WITH RESULT SETS which allow (among other things) to put aliases on the result set of stored procedures.

This example will put aliases on all the columns returned from the stored procedure.

create procedure #testing asbegin select a, b, c from (values (1, 2, 3), (11, 22, 33)) as t(a, b, c);end;goexec #testing WITH RESULT SETS ( ( [Amazing New Name for A] NVARCHAR(100), [The B column is also renamed] NVARCHAR(20), [The C column Renamed] NVARCHAR(30) ) );