How to determine the data type of all fields in a result set in SSDT?
You can use the SELECT..INTO syntax to create a table on-the-fly and examine the resultant column definitions in sys.columns.

select
  *
into #SomeName
from &lt;your query goes here&gt;
where 1=0 -- because we only want the metadata


I think sys.columns has definitons for functions, too, but I don't have an instance to hand just now to check.  Alternately you could create a view with the same query you are about to put into your function and check the catalogue for that.