I have the following code that is pivoting a previous table. The table has two quarters, 2012Q2 and 2012Q3 (these will eventually change so that's why they are parameters at the moment). However, when I run the code, I get "Incorrect syntax near 'Q3'" which is the value of @SimQuarter. When I run the dynamic SQL code without the parameters (actual column names and PERIOD='2012Q3'), it runs just fine. What am I missing?? Any help will be appreciated! declare @HistQtr nvarchar(7) set @HistQtr='2012Q2' declare @SimQuarter nvarchar(7) declare @SQL_UW nvarchar(max) IF OBJECT_ID('AnalyticsV2.CM.CorrelationData_UW', 'U') IS NOT NULL DROP TABLE AnalyticsV2.CM.CorrelationData_UW; set @SimQuarter=(case when @HistQtr like '%Q1%' then left(@HistQtr,4)+'Q2' when @HistQtr like '%Q2%' then left(@HistQtr,4)+'Q3' when @HistQtr like '%Q3%' then left(@HistQtr,4)+'Q4' else cast((cast(left(@HistQtr,4) as float)+1) as nvarchar(5)) +'Q1' end) set @SQL_UW = 'select SIMULATION,' + @colNames +' into AnalyticsV2.CM.CorrelationData_UW from ( select SIMULATION, replace(PRODUCT,''_'','' '') as PRODUCT, Product_Description, Value from AnalyticsV2.CM.CorrelationData where Product_Description=''UW'' and PERIOD='+@SimQuarter+' ) d pivot ( min(Value) for PRODUCT in (' + @colNames+ ') ) piv' exec sp_executesql @SQL_UW