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.
| Author |
Topic |
|
hksharmaa
Starting Member
16 Posts |
Posted - 2010-11-25 : 01:12:23
|
| Hi All...I have written a query which kepts on running ...It takes 1 hour approx. to complete whole query...i need only 1 row...i want it to stop as soon as it shows me 1 row....Is there any way out??? |
|
|
hksharmaa
Starting Member
16 Posts |
Posted - 2010-11-25 : 01:16:04
|
| I am also attaching the query...SELECT F1.[Drum No_], F2.[Drum No_], F3.[Drum No_], F4.[Drum No_], F5.[Drum No_]FROM [Local Sharp$Temp Drum Ledger Entry] AS F1, [Local Sharp$Temp Drum Ledger Entry] AS F2, [Local Sharp$Temp Drum Ledger Entry] AS F3, [Local Sharp$Temp Drum Ledger Entry] AS F4, [Local Sharp$Temp Drum Ledger Entry] AS F5WHERE F1.[Drum No_]<>F2.[Drum No_] AND F2.[Drum No_]<> F3.[Drum No_] AND F3.[Drum No_]<>F4.[Drum No_] AND F4.[Drum No_]<> F5.[Drum No_] AND (F1.TP + F2.TP + F3.TP + F4.TP + F5.TP)/5.0BETWEEN 10. AND 11.0 |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-11-25 : 03:17:54
|
| Hi,SQL doesn't take much time in presentation.Its the processing time that matters.Can you post the ddl for [Local Sharp$Temp Drum Ledger Entry] along with index details.What i see in your query is that you are taking alias of same table five times and using five different values for processing.What version of SQL Server you are using ?Regards,Bohra |
 |
|
|
sathiesh2005
Yak Posting Veteran
85 Posts |
Posted - 2010-11-25 : 03:50:35
|
| did you mean select top 1 cols,....from table??@Sathiesh |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-26 : 02:50:50
|
quote: Originally posted by hksharmaa Hi All...I have written a query which kepts on running ...It takes 1 hour approx. to complete whole query...i need only 1 row...i want it to stop as soon as it shows me 1 row....Is there any way out???
Why do you want only one row?If you want to know if the query returns any rowif exists(your_query)--row existsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|