When i am Printing the sql then @PeriodAlias getting truncated. not all the period is coming in printed sql. please guide me what to change as a result dynamic column should not be truncated. thanks
Declare @PeriodAliasComment NVARCHAR(MAX)
SET @sql = N'
Update #TmpBM Set BM_Element=Output.BM_Element,
'+@UpdateSql+'
From #TmpBM tmp,
(Select Section,LineItem,BM_Code Code,(Case When isnull(a.BM_Element,'''')='''' then b.bm_element else a.BM_Element end) BM_Element,
'+@PeriodAlias+'
From tblWebCSM a INNER JOIN tblBlueMetricsMaster b ON a.BM_code=b.code
Where Ticker='''+@Ticker +''' And Isnull(BM_Code,'''')!='''' And Isnull(BM_Code,'''') In (''01'',''07'',''10'')
) Output
Where tmp.Section=Output.Section And tmp.LineItem=Output.LineItem And tmp.Code=Output.Code