set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetDrillDownFields1]
(@DepartmentID VARCHAR(30),
@CategoryID VARCHAR(30),
@DrillDownClause VARCHAR(3000)
)
AS
DECLARE @DrillDownTable NVARCHAR(4000)
SET @DrillDownTable = '' +
N'SELECT pd.Core, pd.[Multy-Core], pd.HT, pd.FSB ' +
N' INTO ##DrillDownProcessorTable1 ' +
N'FROM Items AS i ' +
N' INNER JOIN ItemCategory AS ic ' +
N' ON i.ItemID = ic.ItemID ' +
N' INNER JOIN Categories AS c ' +
N' ON c.CategoryID = ic.CategoryID ' +
N' INNER JOIN Departments as d ' +
N' ON d.DepartmentID = c.DepartmentID ' +
N' INNER JOIN ProcessorsDetail AS pd ' +
N' ON i.ItemID = pd.ItemID ' +
N'WHERE d.DepartmentID = ' + @DepartmentID + ' AND ' +
N' i.Discontinued = 0 ' +
@DrillDownClause
exec sp_executesql @DrillDownTable
SELECT * FROM ##DrillDownProcessorTable1
|