tags:

views:

51

answers:

2

Is it possible to use select * with distinct or write easily something that has the same impact?

I need to select all columns from a table with distinct value, but listing all the columns in select clause would be nerve-breaking because the number of columns is over 20!

+1  A: 

This should work:

SELECT DISTINCT * FROM TABLE_NAME
codaddict
Would work. But keep in mind: not very fast!
Yves M.
+4  A: 

In Microsoft SQL Server you can write:

select distinct * from MyTable

However, it is considered "best practice" to specify the columns explicitly, partly because it improves the performance of the query, but also to protect yourself from failures that would arise if the database schema were to change in the future

John Sibly