Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace batch update on daily basis
Message
 
 
To
15/02/2009 18:25:09
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Application:
Web
Miscellaneous
Thread ID:
01381959
Message ID:
01381989
Views:
13
>>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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform