This is too long for comment.
There are various ways to output columns from a query, for example:
select top 0 s.*
from (<your query here>) s;
.
. , , :
select top 0 s.*
into _TempTableForColumns
from (<your query here>) s;
information_schema ( , ):
select *
from information_schema.columns
where table_name = '_TempTableForColumns' and schema_name = 'dbo';
drop table _TempTableForColumns;
, . , , . , , , .