Find number of CPU and Cores through T-SQL

SELECT [cpu_count], [cores_per_socket]
FROM [sys].[dm_os_sys_info]