SQL Server does not support
. For example, the below query fails.
SELECT COUNT(DISTINCT *) FROM Employees
The error message generated is:
Incorrect syntax near '*'
Instead, use the below query:
SELECT COUNT(*) FROM (SELECT DISTINCT * FROM Employees) Emp
Note: This is specifically useful when you want 'DISTINCT *' - without coloumn name(s)
Ravikiran Malladi is a senior software professional in Microsoft technologies. He has global IT experience of over 10 years and has compulsive habit of writing tools, particularly for the projects he works on. He has vast experience in the roles of senior developer, technical analyst, technical architect besides in technical lead roles.
His hobbies include chess, music, cricket, web sites along side writing technical articles and technical blogs.