|
SET @SQL='select @parm1= COUNT(*) from '+@Database+'.dbo.FactPersonSnapshot f group by f.EnrollmentMonthDateKey order by f.EnrollmentMonthDateKey ' exec sp_executesql @SQL, @params = N'@parm1 int OUTPUT', @parm1=@parm1 OUTPUT This query has to return multiple rows. Instead it is just outputting the first row. Could anyone pls help. Thanks vs0523
(comments are locked)
|
|
It looks like you are after a count for each month. Because Try something like this (I've used
(comments are locked)
|
|
The query is returning the count of rows from the table - this is a one row, one column output. Plus you are then setting the value to an integer valued output parameter. What multiple rows are you expecting? The query returns count of rows for each month(it is a group by month).This is the query that I tried to modify as above: SET @SQL='select EnrollmentMonthDateKey,COUNT(*) as MemberCount from '+@Database+'.dbo.FactPersonSnapshot f group by f.EnrollmentMonthDateKey order by f.EnrollmentMonthDateKey ' EXEC (@SQL) I was able to get multiple rows with this. But when I am assigning this to variable it is just returning the first row.
Jul 09 '12 at 07:07 PM
vs0523
Sorry - was speed reading on my phone! The reason still stands regarding the single variable though. Ken has shown a way of getting multiple records out.
Jul 09 '12 at 08:06 PM
Kev Riley ♦♦
(comments are locked)
|

