Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Distinct Rows From Sproc

Author  Topic 

beatkeeper25
Starting Member

27 Posts

Posted - 2014-02-13 : 14:17:30
I've pinpointed the sproc responsible for the duplicate values in a report. I need to either alter the sproc to only return distinct rows, or tell the report to only grab distinct rows from the sprocs results. It is a pretty complicated (for me) sproc with multiple joins, subqueries, case statements, etc. I tried to use group by to make it distinct, but I couldn't get it to work. Any ideas without looking at code? I guess I can post sproc if needed.

Thanks.

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2014-02-13 : 15:55:33
Depending on how familiar you are with the database I would lean towards modifying the report query, not the sproc if you have concern.

You can always insert your results into a table

create table #tmp(testcolumn1 varchar(10), testcolumn2 int)
insert into #tmp(testcolumn1,testcolumn2)
exec sproc_myprocedure

select distinct testcolumn1,testcolumn2
from #tmp



Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page
   

- Advertisement -