Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 SQL Server Group by count

Author  Topic 

sariv
Starting Member

1 Post

Posted - 2009-07-04 : 03:25:42
I want to check the count of column , when it group by.
Eg . table test has 2 columns a1, b1
values a1 b1

1 2

1 1
select a1 from test groupby a1
select @@rowcount
returns 1
But the select result is logged in Log file when i run the job, because of the select statement.
I need a solution not to log that select result in Log file.

Thanks in advance
sariv

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-04 : 03:55:59
-- Peso 1
declare @items int

select @items = count(*)
from (
select a1 from test group by a1
) AS d

-- Peso 2
SELECT @Items = COUNT(DISTINCT a1)
FROM Test



Microsoft SQL Server MVP

N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -