Alternative way of finding number of columns.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 217
DECLARE @query nvarchar(4000) = N'select * from employee_master AS TSB';

--Tabular results
EXECUTE sys.sp_describe_first_result_set @tsql = @query;

--Simple column count
SELECT
COUNT(1) AS column_count
FROM
sys.dm_exec_describe_first_result_set(@query, NULL, 0);

Comments or Responses

Login to post response