By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
DECLARE @sql nvarchar(max) = N'SELECT database_id, name FROM sys.databases;';
SELECT name,
system_type_name,
is_nullable
FROM sys.dm_exec_describe_first_result_set(@sql, NULL, 0) AS f
ORDER BY f.column_ordinal;
name | system_type_name | is_nullable |
---|---|---|
database_id | int | False |
name | nvarchar(128) | True |