Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fine tuning a SPROC
Message
 
À
21/06/2007 14:32:20
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01234693
Message ID:
01234839
Vues:
10
On second thought I doubt that will work faster. Again it compares a record from table1 with ALL records from Table2.
Let me think...

>I'll try... thanks!
>
>>Hmmm,
>>How about:
>>
>>DECLARE @Temp TABLE (table1ID int, Table2Id, StartDate Datetime, EndDate DateTime)
>>INSERT INTO @Temp
>>SELECT Table1.Id,
>>       Table2.Id,
>>       Table2.StartDate,
>>       Table2.EndDate
>>FROM Table1
>>FULL JOIN Table2 ON 1=1
>>
>>
>>SELECT .....
>>    FROM Table1
>>    LEFT JOIN @Temp Temp ON Table1.Id = Temp.Id AND Table1.EffectiveDate BETWEEN Temp.StartDate AND Temp.EndDate
>>
>>I am not sure if this would speed something.
>>
>>
>>>Table1 contains a record for each day that contains certain interest rates.
>>>Table2 contains a record for a range of days (specified by StartDate and EndDate - no overlap) that contains other interest rates.
>>>
>>>I want to link the tables, and view the corresponding Table2 record with each Table1 record. The tables are unrelated otherwise.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform