To find the data type of an expression in SQL Server, pass it to SQL_VARIANT_PROPERTY or describe the whole query with sys.dm_exec_describe_first_result_set. This post tests both on a percentage calculation, shows how precision and scale come out, and explains why 2147483647 plus 1 fails.
sp_executesql Output Parameters: Getting Values Back From Dynamic SQL
Dynamic SQL runs in its own scope, so a value only comes back if you ask twice. Here are the two mistakes that leave you with NULL.
SQL SERVER – Export Data From SSMS Query to Excel
This follow-up to copying results to Excel shows how to export data directly from an SSMS query to Excel using Results to File (CTRL + SHIFT + F).
Finding Edition-Bound Features With sys.dm_db_persisted_sku_features
Use sys.dm_db_persisted_sku_features before an edition move, inventory databases, and distinguish feature evidence from licensing checks.
Finding Free Time Slots in a Calendar With GENERATE_SERIES
Find free time slots with GENERATE_SERIES, exclude overlapping bookings, and merge busy intervals before calculating calendar gaps.





