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
 General SQL Server Forums
 New to SQL Server Programming
 Time Elapsed Error

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2011-04-13 : 06:05:03
Hi,

I am working with SQL Server 2005 and have th efollowing problem;

When I run the query below it works fine;

SELECT t1.o_pat_id, t2.prac_no, t2.GoldPracID
FROM gprdsql.TblPracDetails AS t2 INNER JOIN
ODSData5.dbo.o_pat AS t1 ON t2.prac_eid = t1.o_prac_uid


However, when I add a DISTINCT as

SELECT DISTINCT t1.o_pat_id, t2.prac_no, t2.GoldPracID
FROM gprdsql.TblPracDetails AS t2 INNER JOIN
ODSData5.dbo.o_pat AS t1 ON t2.prac_eid = t1.o_prac_uid


I receive the SQL Execution error - Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding..

Any help please!! I thought when I added the Distinct the query should produce the results instantly..

Thnak you

raghuveer125
Constraint Violating Yak Guru

285 Posts

Posted - 2011-04-13 : 07:08:52
You have to try like this
select distinct t1.o_part_id from (SELECT t1.o_pat_id, t2.prac_no, t2.GoldPracID
FROM gprdsql.TblPracDetails AS t2 INNER JOIN
ODSData5.dbo.o_pat AS t1 ON t2.prac_eid = t1.o_prac_uid) as t



Raghu' S
Go to Top of Page

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2011-04-13 : 07:52:34
Tried;

SELECT DISTINCT t1.o_pat_id
FROM (SELECT t1.o_pat_id, t2.prac_no, t2.GoldPracID
FROM gprdsql.TblPracDetails AS t2 INNER JOIN
ODSData5.dbo.o_pat AS t1 ON t2.prac_eid = t1.o_prac_uid) AS t

I received an error- The multi-part identifier "t1.o_pat_id" could not be bound..

any ideas.. thanks

Go to Top of Page
   

- Advertisement -