August 9, 2006 at 10:40 pm
Hello friends
We are using lots of views in our application..its a report kind of thing...so there are many select queries with joins in views...so my query is if there is join the should i always use distinct keyword...because we are getting duplicate rows here most of times....
Regards,
Papillon
August 10, 2006 at 12:31 am
You shuold NOT use keyword DISTINCT in views unless it's a view for user interface.
Duplicate rows mean you've got mess in your data. Clean it up.
_____________
Code for TallyGenerator
August 10, 2006 at 2:30 am
Check your joins, it may be that you have unintentional cross joins. Otherwise work out why you have duplicate rows and fix the source of the problem, don't fix the symptoms.
Distincts are expensive, they force SQL to sort the resultset, requiring temp work tables and all sorts of mess.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply