Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replace batch update on daily basis
Message
 
 
À
15/02/2009 18:25:09
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Web
Divers
Thread ID:
01381959
Message ID:
01381989
Vues:
14
>>try
>>
>>UPDATE StatisticDaily
>>		SET UserCount = uc.CountHit
>>	FROM StatisticDaily 
>>		JOIN (
>>				SELECT DATEADD(day, DATEDIFF(day, 0, AddDate), 0) AS HitDate, 
>>						COUNT(DISTINCT AddUser) AS CountHit 
>>					FROM Hit 
>>					GROUP BY DATEADD(day, DATEDIFF(day, 0, AddDate),0)
>>				) uc ON uc.HitDate = StatisticDaily.date
>>
>
>This is one of the greatest SQL command I have ever seen. I really do not know where you find those. lol This works perfectly. I was able to update the entire table in a minute.
>
>Thanks

If you say so. :) I don't see anything special about it.
As you saw, I wrote it step by step. Making it into UPDATE was simple.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform