How do I return the SQL data types from my query?

前端 未结 13 1494
耶瑟儿~
耶瑟儿~ 2021-01-29 23:58

I\'ve a SQL query that queries an enormous (as in, hundreds of views/tables with hard-to-read names like CMM-CPP-FAP-ADD) database that I don\'t need nor want to understand. Th

13条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 00:40

    For SQL Server 2012 and above: If you place the query into a string then you can get the result set data types like so:

    DECLARE @query nvarchar(max) = 'select 12.1 / 10.1 AS [Column1]';
    EXEC sp_describe_first_result_set @query, null, 0;  
    

提交回复
热议问题