Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Monthly events calendar
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00779571
Message ID:
00779586
Vues:
13
This message has been marked as a message which has helped to the initial question of the thread.
>>I realized that my comment about SQL Server using or not any index to optimize query is irrelevant for '@FirstOfTheMonth + 0 BETWEEN StartDate And EndDate' expression because those checks performed on the column level so they will not be used to optimeze query anyway. You can add one more condition to your query to speed it up
WHERE (StartDate BETWEEN @FirstOfTheMonth And @LastOfTheMonth 
  OR EndDate BETWEEN @FirstOfTheMonth And @LastOfTheMonth )
>
>Why it's an OR condition (should be AND, I think). Should it be for all days, right? Where should I put it? Can you give me the whole query again, please. I have hard time thinking this late at night...

Yes, it has to be 'OR' because event could start in one month and end in another. If you change it to 'AND' you'll get only events that start and end in the current month. You will put this WHERE clause right after FROM clause, as usual. :)
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform