— Return all data types used in the user tables of a database.

select ty.name as DataType, count(*) as NumberOfUses
from sys.tables as t
join sys.columns as c
on c.[object_id] = t.[object_id]
join sys.types as ty
on ty.user_type_id = c.user_type_id
where t.is_ms_shipped = 0
group by ty.name
order by ty.name

go