Pages

Showing posts with label count. Show all posts
Showing posts with label count. Show all posts

Monday, November 16, 2009

Updating counts in a table

update t
set [count] = x.cnt
from [servername].[dbname].[dbo].[table1] t,
(Select tk,count(ID) as cnt from [servername].[dbname].dbo.table2 with (nolock) group by tk) x
where x.tk=t.tk