Skip to content
 

Select Distinct

Select Distinct a way to tell SQL Server to not return duplicate rows. Adding the distinct keyword makes it an expensive query because it essentially performs a group by for all of the returned columns. That being the case, it should only optimally be used on queries that return a small number of rows, or small number of columns.

When using Select Distinct, you should keep in mind that this is generally a workaround to either improper joining of tables, or an improper where clause that is not limiting the result set to only returning one instance of a record.

In order to utilize distinct, all you need to do, is place it before the select list.

SELECT DISTINCT *
FROM yourtable

This will surely only return a unique instance of every record in the result.



Popular search terms:

post a comment OR Post Your Question on our ASK! Community!