I need to make sure the data rows selected in a query are unique. The database table is huge. I did a test by running the following query and it takes 10-20 seconds to complete.
SELECT COUNT(*) FROM (SELECT DISTINCT * FROM dbo.MyTable ) AS a
I wonder which appraoch would have better performance:
1. simply put the above statement in my stored procedure.
2. create a view that does SELECT DISTINCT * FROM dbo.MyTable, and then select data rows from the created view from my stored procedure.
Please comment. Thanks.