SOLVED:
ALTER PROCEDURE GetMaxCostCenterValue
(
@CostCenter nvarchar(225),
@DateFrom datetime,
@DateTo datetime
)
AS
SET NOCOUNT ON
BEGIN
DECLARE @Query NVARCHAR(525)
DECLARE @pn_CostCenter NVARCHAR(525)
SET @Query = N'SELECT
dbo.Formatdate(m.Month) As Financial_Month
, d.Dept_name
,m.'+@CostCenter+'
FROM
tblMasterTable m
INNER JOIN tbldept d
ON d.Dept_ID = m.dept
Where
'+@CostCenter+' =
(SELECT MAX('+@CostCenter+')...