How do I make the following code a stored procedure? I want to connect a crystal report or Excel to the stored procedure and have the user prompted for the year. the code below returns a list of customers with Sales by each month having each column a different month. DECLARE @listCol VARCHAR(2000)DECLARE @query VARCHAR(4000)--DECLARE @YEAR numericSELECT @listCol = STUFF(( SELECT DISTINCT '],[' + ltrim(str(Month(inv_dt))) FROM oehdrhst_sql ORDER BY '],[' + ltrim(str(Month(inv_dt))) FOR XML PATH('') ), 1, 2, '') + ']'SET @query ='SELECT * FROM (SELECT cus_no, Month(inv_dt) OrderYear, tot_sls_amt FROM oehdrhst_sql where year(inv_dt)=2002 ) srcPIVOT (SUM(tot_sls_amt) FOR OrderYearIN ('+@listCol+')) AS pvt' EXECUTE (@query)