Each GROUP BY expression must contain at least one column that is notan outer reference I have a stored procedure as follows
ALTER PROCEDURE [dbo].
[spLoaderCoverageObjectTypeActionTypeWithOptional]
-- Add the parameters for the stored procedure here
@ObjectClass sysname,
@ObjectType sysname,
@RecordAction sysname,
@FieldName sysname
AS
BEGIN
SELECT DISTINCT @ObjectClass as ObjectClass,@ObjectType as
ObjectType,@RecordAction as RecordAction,@FieldName as FieldName,
COUNT(*) AS VALIDCount--,
/*(select Count(*) from TestData6061.dbo.accounting WHERE
(AutomationType LIKE 'loader') AND ([Negative Testcase] = 0) AND
(@ObjectType = @ObjectType) AND (@RecordAction = 'New') AND
('['+@FieldName+'] ' IS NULL)
GROUP BY [01-RecordClass],[02-RecordAction]) as NULLCount*/
FROM TestData6061.dbo.accounting
WHERE (AutomationType LIKE 'loader') AND ([Negative Testcase] =
0) AND (@ObjectType = @ObjectType) AND (@RecordAction = 'New') AND
('['+@FieldName+'] ' IS NOT NULL)
GROUP BY [01-RecordClass],[02-RecordAction],@FieldName
END
I call the stored procedure as
exec spLoaderCoverageObjectTypeActionTypeWithOptional
'accounting','AccountingParameters','New','13-
OverdueOpeningTargetAccount'
and I am seeing the above mentioned error. If I remove the
'@fieldname' in the GROUPBY clause the query works but the result is
not really what I want.
Are there any solutions or workaround for this? |