Tuesday, March 1, 2011

Getting no. of rows affected after running select query in SQL Server 2005

Hi friends,

Below is my query

select    
@monNameStr as [MName],       
IsNull(count(c.AssignmentID),0),          
IsNull(sum(s.ACV),0),         
IsNull(sum(s.GrossReturn),0),         
IsNull(sum(s.NetReturn),0),       
IsNull(avg(a.Total),0)       
FROM

dbo.Assignment_ClaimInfo c,       
dbo.Assignment_SettlementInfo s,          
dbo.Assignment_AdvCharges a      

Where
c.Assignmentid=s.Assignmentid and         
s.Assignmentid=a.Assignmentid and         
a.Assignmentid in          

(select AssignmentID from dbo.Assignment_ClaimInfo         
where (upper(InsuranceComp)=upper(@CompName) or upper(@CompName)='ALL COMPANIES') 
and (DateName(month,DATEADD(month, 0, DOFileClosed))+' '
+cast(year(DATEADD(month, 0, DOFileClosed)) as varchar)=@monNameStr))
Group By c.InsuranceComp
Order By c.InsuranceComp

where @monNameStr is calculated date field like 'October 2009'

What i need to know the no. of records affected by this select query.

I DONT NEED TO NEST THIS QUERY TO ANOTHER QUERY WITH COUNT() FUNCTION.

Your valuable help is appreciated.

From stackoverflow

0 comments:

Post a Comment